Skip to content

Commit 29628d6

Browse files
authored
Merge pull request #668 from upstash/feat/tokens-param
2 parents 39686a9 + 02d87cf commit 29628d6

File tree

2 files changed

+20
-32
lines changed

2 files changed

+20
-32
lines changed

‎README.md‎

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ Check out our [project addition guide](./docs/adding-projects.md) to learn how t
5050
- Cursor, Claude Code, VSCode, Windsurf or another MCP Client
5151
- Context7 API Key (Optional for higher rate limits) (Get yours by creating an account at [context7.com/dashboard](https://context7.com/dashboard))
5252

53+
> [!WARNING]
54+
> **SSE Protocol Deprecation Notice**
55+
>
56+
> The Server-Sent Events (SSE) transport protocol is deprecated and its endpoint will be removed in upcoming releases. Please use HTTP or stdio transport methods instead.
57+
5358
<details>
5459
<summary><b>Installing via Smithery</b></summary>
5560

@@ -117,12 +122,6 @@ Run this command. See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/
117122
claude mcp add --transport http context7 https://mcp.context7.com/mcp --header "CONTEXT7_API_KEY: YOUR_API_KEY"
118123
```
119124

120-
Or using SSE transport:
121-
122-
```sh
123-
claude mcp add --transport sse context7 https://mcp.context7.com/sse --header "CONTEXT7_API_KEY: YOUR_API_KEY"
124-
```
125-
126125
#### Claude Code Local Server Connection
127126

128127
```sh
@@ -335,7 +334,8 @@ See [Gemini CLI Configuration](https://google-gemini.github.io/gemini-cli/docs/t
335334
"context7": {
336335
"httpUrl": "https://mcp.context7.com/mcp",
337336
"headers": {
338-
"CONTEXT7_API_KEY": "YOUR_API_KEY"
337+
"CONTEXT7_API_KEY": "YOUR_API_KEY",
338+
"Accept": "application/json, text/event-stream"
339339
}
340340
}
341341
}
@@ -757,7 +757,7 @@ Add this to your Visual Studio MCP config file (see the [Visual Studio docs](htt
757757
"inputs": [],
758758
"servers": {
759759
"context7": {
760-
"type": "sse",
760+
"type": "http",
761761
"url": "https://mcp.context7.com/mcp",
762762
"headers": {
763763
"CONTEXT7_API_KEY": "YOUR_API_KEY"
@@ -809,23 +809,6 @@ Add this to your Crush configuration file. See [Crush MCP docs](https://github.c
809809
}
810810
```
811811

812-
#### Crush Remote Server Connection (SSE)
813-
814-
```json
815-
{
816-
"$schema": "https://charm.land/crush.json",
817-
"mcp": {
818-
"context7": {
819-
"type": "sse",
820-
"url": "https://mcp.context7.com/sse",
821-
"headers": {
822-
"CONTEXT7_API_KEY": "YOUR_API_KEY"
823-
}
824-
}
825-
}
826-
}
827-
```
828-
829812
#### Crush Local Server Connection
830813

831814
```json
@@ -992,7 +975,7 @@ Context7 MCP provides the following tools that LLMs can use:
992975
- `get-library-docs`: Fetches documentation for a library using a Context7-compatible library ID.
993976
- `context7CompatibleLibraryID` (required): Exact Context7-compatible library ID (e.g., `/mongodb/docs`, `/vercel/next.js`)
994977
- `topic` (optional): Focus the docs on a specific topic (e.g., "routing", "hooks")
995-
- `tokens` (optional, default 10000): Max number of tokens to return. Values less than the default value of 10000 are automatically increased to 10000.
978+
- `tokens` (optional, default 5000): Max number of tokens to return. Values less than 1000 are automatically increased to 1000.
996979

997980
## 🛟 Tips
998981

‎src/index.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
1212
import { Command } from "commander";
1313
import { IncomingMessage } from "http";
1414

15-
const DEFAULT_MINIMUM_TOKENS = 10000;
15+
/** Minimum allowed tokens for documentation retrieval */
16+
const MINIMUM_TOKENS = 1000;
17+
/** Default tokens when none specified */
18+
const DEFAULT_TOKENS = 5000;
19+
/** Default HTTP server port */
20+
const DEFAULT_PORT = 3000;
1621

1722
// Parse CLI arguments using commander
1823
const program = new Command()
1924
.option("--transport <stdio|http>", "transport type", "stdio")
20-
.option("--port <number>", "port for HTTP transport", "3000")
25+
.option("--port <number>", "port for HTTP transport", DEFAULT_PORT.toString())
2126
.option("--api-key <key>", "API key for authentication")
2227
.allowUnknownOption() // let MCP Inspector / other wrappers pass through extra flags
2328
.parse(process.argv);
@@ -200,14 +205,14 @@ ${resultsText}`,
200205
.describe("Topic to focus documentation on (e.g., 'hooks', 'routing')."),
201206
tokens: z
202207
.preprocess((val) => (typeof val === "string" ? Number(val) : val), z.number())
203-
.transform((val) => (val < DEFAULT_MINIMUM_TOKENS ? DEFAULT_MINIMUM_TOKENS : val))
208+
.transform((val) => (val < MINIMUM_TOKENS ? MINIMUM_TOKENS : val))
204209
.optional()
205210
.describe(
206-
`Maximum number of tokens of documentation to retrieve (default: ${DEFAULT_MINIMUM_TOKENS}). Higher values provide more context but consume more tokens.`
211+
`Maximum number of tokens of documentation to retrieve (default: ${DEFAULT_TOKENS}). Higher values provide more context but consume more tokens.`
207212
),
208213
},
209214
},
210-
async ({ context7CompatibleLibraryID, tokens = DEFAULT_MINIMUM_TOKENS, topic = "" }) => {
215+
async ({ context7CompatibleLibraryID, tokens = DEFAULT_TOKENS, topic = "" }) => {
211216
const fetchDocsResponse = await fetchLibraryDocumentation(
212217
context7CompatibleLibraryID,
213218
{
@@ -248,7 +253,7 @@ async function main() {
248253

249254
if (transportType === "http") {
250255
// Get initial port from environment or use default
251-
const initialPort = CLI_PORT ?? 3000;
256+
const initialPort = CLI_PORT ?? DEFAULT_PORT;
252257
// Keep track of which port we end up using
253258
let actualPort = initialPort;
254259
const httpServer = createServer(async (req, res) => {

0 commit comments

Comments
 (0)