Skip to main content
Glama
sawroop1242

OpenRouter Reasoning MCP

by sawroop1242
README.md
# OpenRouter Reasoning MCP

A stateless remote Model Context Protocol (MCP) server running on Cloudflare Workers.

It exposes one tool, `multi_step_reasoning`, which sends a prompt to OpenRouter, performs a second verification pass, and returns both responses plus provider reasoning fields when available.

## Architecture

```text
MCP client
   │
   │ Streamable HTTP
   ▼
Cloudflare Worker /mcp
   │
   ├── OpenRouter request #1
   │
   └── OpenRouter request #2 (verification)
             │
             ▼
      OpenRouter model
      stealth/ox-alpha
```

## Requirements

- Node.js
- A Cloudflare account
- An OpenRouter API key
- Wrangler authentication

## Local development

```bash
npm install
npx wrangler login
npx wrangler secret put OPENROUTER_API_KEY
npm run dev
```

The MCP endpoint is `/mcp`.

## Deploy

```bash
npm install
npx wrangler login
npx wrangler secret put OPENROUTER_API_KEY
npm run typecheck
npm run deploy
```

After deployment, the endpoint will be:

```text
https://openrouter-reasoning-mcp.<your-subdomain>.workers.dev/mcp
```

## MCP client configuration

Use the deployed `/mcp` URL as a remote MCP server using Streamable HTTP. Do not configure the endpoint as the deprecated HTTP+SSE transport.

## Tool

### `multi_step_reasoning`

Input:

```json
{
  "prompt": "Explain why a binary search is O(log n).",
  "follow_up": "Verify the explanation and correct any mistakes."
}
```

`follow_up` is optional. The default is:

```text
Are you sure? Think carefully and verify your answer.
```

## Security

The OpenRouter key is stored as a Cloudflare Worker secret and is never committed to Git. The current server is intentionally unauthenticated, meaning anyone who can reach the `/mcp` endpoint can invoke the tool and consume the configured OpenRouter account. Add MCP authentication/authorization before using this publicly with a paid OpenRouter key.

## License

MIT