@upstash/context7-mcp 1.0.15 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ![Cover](public/cover.png)
2
+
1
3
  # Context7 MCP - Up-to-date Code Docs For Any Prompt
2
4
 
3
5
  [![Website](https://img.shields.io/badge/Website-context7.com-blue)](https://context7.com) [![smithery badge](https://smithery.ai/badge/@upstash/context7-mcp)](https://smithery.ai/server/@upstash/context7-mcp)
@@ -11,7 +13,7 @@
11
13
  LLMs rely on outdated or generic information about the libraries you use. You get:
12
14
 
13
15
  - ❌ Code examples are outdated and based on year-old training data
14
- - ❌ Hallucinated APIs don't even exist
16
+ - ❌ Hallucinated APIs that don't even exist
15
17
  - ❌ Generic answers for old package versions
16
18
 
17
19
  ## ✅ With Context7
@@ -46,7 +48,12 @@ Check out our [project addition guide](./docs/adding-projects.md) to learn how t
46
48
 
47
49
  - Node.js >= v18.0.0
48
50
  - Cursor, Claude Code, VSCode, Windsurf or another MCP Client
49
- - Context7 API Key (Optional for higher rate limits) (Get yours by creating an account at [context7.com/console](https://context7.com/console))
51
+ - Context7 API Key (Optional for higher rate limits) (Get yours by creating an account at [context7.com/dashboard](https://context7.com/dashboard))
52
+
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.
50
57
 
51
58
  <details>
52
59
  <summary><b>Installing via Smithery</b></summary>
@@ -107,7 +114,7 @@ Pasting the following configuration into your Cursor `~/.cursor/mcp.json` file i
107
114
  <details>
108
115
  <summary><b>Install in Claude Code</b></summary>
109
116
 
110
- Run this command. See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/tutorials#set-up-model-context-protocol-mcp) for more info.
117
+ Run this command. See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/claude-code/mcp) for more info.
111
118
 
112
119
  #### Claude Code Remote Server Connection
113
120
 
@@ -115,12 +122,6 @@ Run this command. See [Claude Code MCP docs](https://docs.anthropic.com/en/docs/
115
122
  claude mcp add --transport http context7 https://mcp.context7.com/mcp --header "CONTEXT7_API_KEY: YOUR_API_KEY"
116
123
  ```
117
124
 
118
- Or using SSE transport:
119
-
120
- ```sh
121
- claude mcp add --transport sse context7 https://mcp.context7.com/sse --header "CONTEXT7_API_KEY: YOUR_API_KEY"
122
- ```
123
-
124
125
  #### Claude Code Local Server Connection
125
126
 
126
127
  ```sh
@@ -333,7 +334,8 @@ See [Gemini CLI Configuration](https://google-gemini.github.io/gemini-cli/docs/t
333
334
  "context7": {
334
335
  "httpUrl": "https://mcp.context7.com/mcp",
335
336
  "headers": {
336
- "CONTEXT7_API_KEY": "YOUR_API_KEY"
337
+ "CONTEXT7_API_KEY": "YOUR_API_KEY",
338
+ "Accept": "application/json, text/event-stream"
337
339
  }
338
340
  }
339
341
  }
@@ -752,11 +754,13 @@ Add this to your Visual Studio MCP config file (see the [Visual Studio docs](htt
752
754
 
753
755
  ```json
754
756
  {
755
- "mcp": {
756
- "servers": {
757
- "context7": {
758
- "type": "http",
759
- "url": "https://mcp.context7.com/mcp"
757
+ "inputs": [],
758
+ "servers": {
759
+ "context7": {
760
+ "type": "http",
761
+ "url": "https://mcp.context7.com/mcp",
762
+ "headers": {
763
+ "CONTEXT7_API_KEY": "YOUR_API_KEY"
760
764
  }
761
765
  }
762
766
  }
@@ -805,23 +809,6 @@ Add this to your Crush configuration file. See [Crush MCP docs](https://github.c
805
809
  }
806
810
  ```
807
811
 
808
- #### Crush Remote Server Connection (SSE)
809
-
810
- ```json
811
- {
812
- "$schema": "https://charm.land/crush.json",
813
- "mcp": {
814
- "context7": {
815
- "type": "sse",
816
- "url": "https://mcp.context7.com/sse",
817
- "headers": {
818
- "CONTEXT7_API_KEY": "YOUR_API_KEY"
819
- }
820
- }
821
- }
822
- }
823
- ```
824
-
825
812
  #### Crush Local Server Connection
826
813
 
827
814
  ```json
@@ -983,13 +970,12 @@ See [Local and Remote MCPs for Perplexity](https://www.perplexity.ai/help-center
983
970
  Context7 MCP provides the following tools that LLMs can use:
984
971
 
985
972
  - `resolve-library-id`: Resolves a general library name into a Context7-compatible library ID.
986
-
987
973
  - `libraryName` (required): The name of the library to search for
988
974
 
989
975
  - `get-library-docs`: Fetches documentation for a library using a Context7-compatible library ID.
990
976
  - `context7CompatibleLibraryID` (required): Exact Context7-compatible library ID (e.g., `/mongodb/docs`, `/vercel/next.js`)
991
977
  - `topic` (optional): Focus the docs on a specific topic (e.g., "routing", "hooks")
992
- - `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.
993
979
 
994
980
  ## 🛟 Tips
995
981
 
@@ -1015,6 +1001,10 @@ Context7 MCP provides the following tools that LLMs can use:
1015
1001
  >
1016
1002
  > The slash syntax tells the MCP tool exactly which library to load docs for.
1017
1003
 
1004
+ ### HTTPS Proxy
1005
+
1006
+ If you are behind an HTTP proxy, Context7 uses the standard `https_proxy` / `HTTPS_PROXY` environment variables.
1007
+
1018
1008
  ## 💻 Development
1019
1009
 
1020
1010
  Clone the project and install dependencies:
@@ -1041,7 +1031,7 @@ bun run dist/index.js
1041
1031
 
1042
1032
  - `--transport <stdio|http>` – Transport to use (`stdio` by default). Note that HTTP transport automatically provides both HTTP and SSE endpoints.
1043
1033
  - `--port <number>` – Port to listen on when using `http` transport (default `3000`).
1044
- - `--api-key <key>` – API key for authentication. You can get your API key by creating an account at [context7.com/console](https://context7.com/console).
1034
+ - `--api-key <key>` – API key for authentication. You can get your API key by creating an account at [context7.com/dashboard](https://context7.com/dashboard).
1045
1035
 
1046
1036
  Example with http transport and port 8080:
1047
1037
 
package/dist/index.js CHANGED
@@ -8,11 +8,16 @@ import { createServer } from "http";
8
8
  import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
9
9
  import { SSEServerTransport } from "@modelcontextprotocol/sdk/server/sse.js";
10
10
  import { Command } from "commander";
11
- const DEFAULT_MINIMUM_TOKENS = 10000;
11
+ /** Minimum allowed tokens for documentation retrieval */
12
+ const MINIMUM_TOKENS = 1000;
13
+ /** Default tokens when none specified */
14
+ const DEFAULT_TOKENS = 5000;
15
+ /** Default HTTP server port */
16
+ const DEFAULT_PORT = 3000;
12
17
  // Parse CLI arguments using commander
13
18
  const program = new Command()
14
19
  .option("--transport <stdio|http>", "transport type", "stdio")
15
- .option("--port <number>", "port for HTTP transport", "3000")
20
+ .option("--port <number>", "port for HTTP transport", DEFAULT_PORT.toString())
16
21
  .option("--api-key <key>", "API key for authentication")
17
22
  .allowUnknownOption() // let MCP Inspector / other wrappers pass through extra flags
18
23
  .parse(process.argv);
@@ -72,7 +77,7 @@ function getClientIp(req) {
72
77
  function createServerInstance(clientIp, apiKey) {
73
78
  const server = new McpServer({
74
79
  name: "Context7",
75
- version: "1.0.15",
80
+ version: "1.0.17",
76
81
  }, {
77
82
  instructions: "Use this server to retrieve up-to-date documentation and code examples for any library.",
78
83
  });
@@ -154,11 +159,11 @@ ${resultsText}`,
154
159
  .describe("Topic to focus documentation on (e.g., 'hooks', 'routing')."),
155
160
  tokens: z
156
161
  .preprocess((val) => (typeof val === "string" ? Number(val) : val), z.number())
157
- .transform((val) => (val < DEFAULT_MINIMUM_TOKENS ? DEFAULT_MINIMUM_TOKENS : val))
162
+ .transform((val) => (val < MINIMUM_TOKENS ? MINIMUM_TOKENS : val))
158
163
  .optional()
159
- .describe(`Maximum number of tokens of documentation to retrieve (default: ${DEFAULT_MINIMUM_TOKENS}). Higher values provide more context but consume more tokens.`),
164
+ .describe(`Maximum number of tokens of documentation to retrieve (default: ${DEFAULT_TOKENS}). Higher values provide more context but consume more tokens.`),
160
165
  },
161
- }, async ({ context7CompatibleLibraryID, tokens = DEFAULT_MINIMUM_TOKENS, topic = "" }) => {
166
+ }, async ({ context7CompatibleLibraryID, tokens = DEFAULT_TOKENS, topic = "" }) => {
162
167
  const fetchDocsResponse = await fetchLibraryDocumentation(context7CompatibleLibraryID, {
163
168
  tokens,
164
169
  topic,
@@ -188,7 +193,7 @@ async function main() {
188
193
  const transportType = TRANSPORT_TYPE;
189
194
  if (transportType === "http") {
190
195
  // Get initial port from environment or use default
191
- const initialPort = CLI_PORT ?? 3000;
196
+ const initialPort = CLI_PORT ?? DEFAULT_PORT;
192
197
  // Keep track of which port we end up using
193
198
  let actualPort = initialPort;
194
199
  const httpServer = createServer(async (req, res) => {
package/dist/lib/api.js CHANGED
@@ -1,6 +1,26 @@
1
1
  import { generateHeaders } from "./encryption.js";
2
+ import { ProxyAgent, setGlobalDispatcher } from "undici";
2
3
  const CONTEXT7_API_BASE_URL = "https://context7.com/api";
3
4
  const DEFAULT_TYPE = "txt";
5
+ // Pick up proxy configuration in a variety of common env var names.
6
+ const PROXY_URL = process.env.HTTPS_PROXY ??
7
+ process.env.https_proxy ??
8
+ process.env.HTTP_PROXY ??
9
+ process.env.http_proxy ??
10
+ null;
11
+ if (PROXY_URL && !PROXY_URL.startsWith("$") && /^(http|https):\/\//i.test(PROXY_URL)) {
12
+ try {
13
+ // Configure a global proxy agent once at startup. Subsequent fetch calls will
14
+ // automatically use this dispatcher.
15
+ // Using `any` cast because ProxyAgent implements the Dispatcher interface but
16
+ // TS may not infer it correctly in some versions.
17
+ setGlobalDispatcher(new ProxyAgent(PROXY_URL));
18
+ }
19
+ catch (error) {
20
+ // Don't crash the app if proxy initialisation fails – just log a warning.
21
+ console.error(`[Context7] Failed to configure proxy agent for provided proxy URL: ${PROXY_URL}:`, error);
22
+ }
23
+ }
4
24
  /**
5
25
  * Searches for libraries matching the given query
6
26
  * @param query The search query
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@upstash/context7-mcp","version":"1.0.15","description":"MCP server for Context7","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc && chmod 755 dist/index.js","format":"prettier --write .","lint":"eslint \"**/*.{js,ts,tsx}\" --fix","lint:check":"eslint \"**/*.{js,ts,tsx}\"","start":"node dist/index.js --transport http","pack-dxt":"bun install && bun run build && rm -rf node_modules && bun install --production && mv dxt/.dxtignore .dxtignore && mv dxt/manifest.json manifest.json && dxt validate manifest.json && dxt pack . dxt/context7.dxt && mv manifest.json dxt/manifest.json && mv .dxtignore dxt/.dxtignore && bun install"},"repository":{"type":"git","url":"git+https://github.com/upstash/context7.git"},"keywords":["modelcontextprotocol","mcp","context7"],"author":"abdush","license":"MIT","type":"module","bin":{"context7-mcp":"dist/index.js"},"files":["dist"],"bugs":{"url":"https://github.com/upstash/context7/issues"},"homepage":"https://github.com/upstash/context7#readme","dependencies":{"@modelcontextprotocol/sdk":"^1.13.2","commander":"^14.0.0","zod":"^3.24.2"},"devDependencies":{"@types/node":"^22.13.14","@typescript-eslint/eslint-plugin":"^8.28.0","@typescript-eslint/parser":"^8.28.0","eslint":"^9.23.0","eslint-config-prettier":"^10.1.1","eslint-plugin-prettier":"^5.2.5","prettier":"^3.5.3","typescript":"^5.8.2","typescript-eslint":"^8.28.0"}}
1
+ {"name":"@upstash/context7-mcp","version":"1.0.17","description":"MCP server for Context7","scripts":{"test":"echo \"Error: no test specified\" && exit 1","build":"tsc && chmod 755 dist/index.js","format":"prettier --write .","lint":"eslint \"**/*.{js,ts,tsx}\" --fix","lint:check":"eslint \"**/*.{js,ts,tsx}\"","start":"node dist/index.js --transport http","pack-dxt":"bun install && bun run build && rm -rf node_modules && bun install --production && mv dxt/.dxtignore .dxtignore && mv dxt/manifest.json manifest.json && dxt validate manifest.json && dxt pack . dxt/context7.dxt && mv manifest.json dxt/manifest.json && mv .dxtignore dxt/.dxtignore && bun install"},"repository":{"type":"git","url":"git+https://github.com/upstash/context7.git"},"keywords":["modelcontextprotocol","mcp","context7"],"author":"abdush","license":"MIT","type":"module","bin":{"context7-mcp":"dist/index.js"},"files":["dist"],"bugs":{"url":"https://github.com/upstash/context7/issues"},"homepage":"https://github.com/upstash/context7#readme","dependencies":{"@modelcontextprotocol/sdk":"^1.13.2","commander":"^14.0.0","undici":"^6.6.3","zod":"^3.24.2"},"devDependencies":{"@types/node":"^22.13.14","@typescript-eslint/eslint-plugin":"^8.28.0","@typescript-eslint/parser":"^8.28.0","eslint":"^9.34.0","eslint-config-prettier":"^10.1.1","eslint-plugin-prettier":"^5.2.5","prettier":"^3.6.2","typescript":"^5.8.2","typescript-eslint":"^8.28.0"}}