# cht.sh MCP Server for Cursor

A Model Context Protocol (MCP) server that integrates the powerful `cht.sh` cheat sheet service with Cursor. This allows AI agents and users to quickly fetch programming language syntax, commands, and examples directly within the Cursor editor.

## NPX Usage

The simplest way to use this MCP server is with npx:

```bash
npx @travisjbeck/ch-sh-mcp
```

This command will start the MCP server, making it available for Cursor to connect.

## Features

- **Direct `cht.sh` Queries**: Leverages the extensive `cht.sh` database for cheat sheets.
- **Flexible Querying**: Supports multi-word queries (e.g., "python http server") and `cht.sh` specific options.
- **AI Agent Focused**: Designed to provide concise and relevant information for AI-assisted coding.

## AI Agent Tool

- **`query_cheatsheet`**: Fetches a cheat sheet from `cht.sh`.
  - **Parameters**:
    - `query` (string, required): The search term or topic (e.g., "javascript array methods", "git commit").
    - `options` (string, optional): Optional `cht.sh` query parameters (e.g., "Tq" for terse output without comments, "Q" for quiet mode). Refer to `cht.sh/:help` for all options.
  - **Returns**: The text content of the fetched cheat sheet.

## Setup in Cursor

1.  Open Cursor and go to `Settings > Cursor Settings > MCP`.
2.  Click `+ Add new global MCP server`.
3.  Fill in the fields:
    *   **Name**: `cht.sh Server` (or any preferred name)
    *   **Type**: `command`
    *   **Command**: `npx @travisjbeck/ch-sh-mcp`
4.  Click `Add`.
5.  Restart Cursor to ensure the new MCP server is recognized.

## Manual Installation (Optional)

If you prefer to install the package globally:

```bash
npm install -g @travisjbeck/ch-sh-mcp
```

Then, in Cursor's MCP settings, set the command to simply `@travisjbeck/ch-sh-mcp`.

## For Developers

### Prerequisites

- Node.js (v18.0.0 or higher)
- npm

### Installation from Source

```bash
git clone https://github.com/travisjbeck/ch-sh-mcp.git
cd ch-sh-mcp
npm install
```

### Building

```bash
npm run build
```

This compiles the TypeScript source to JavaScript in the `dist` directory.

### Running Locally for Development

```bash
npm run dev
```

This will start the server using `ts-node` for live reloading.

### Testing

Manual testing with Cursor is recommended. Configure Cursor to use your local development server (e.g., `node dist/index.js` or the `npm run dev` command).

The server includes basic error handling and will output logs to `stderr`.

### Project Structure

-   `src/index.ts`: The main MCP server implementation.
-   `package.json`: Project metadata, dependencies, and scripts.
-   `tsconfig.json`: TypeScript compiler configuration.

## License

MIT - See [LICENSE](LICENSE) for details. 