@upstash/context7-mcp 1.0.24 → 1.0.26
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/dist/index.js +17 -11
- package/dist/lib/api.js +6 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -74,13 +74,15 @@ function getClientIp(req) {
|
|
|
74
74
|
return undefined;
|
|
75
75
|
}
|
|
76
76
|
// Function to create a new server instance with all tools registered
|
|
77
|
-
function createServerInstance(clientIp, apiKey) {
|
|
77
|
+
function createServerInstance(clientIp, apiKey, transportType) {
|
|
78
78
|
const server = new McpServer({
|
|
79
79
|
name: "Context7",
|
|
80
|
-
version: "1.0.
|
|
80
|
+
version: "1.0.26",
|
|
81
81
|
}, {
|
|
82
82
|
instructions: "Use this server to retrieve up-to-date documentation and code examples for any library.",
|
|
83
83
|
});
|
|
84
|
+
// Deprecation notice for SSE users
|
|
85
|
+
const sseDeprecationNotice = "\n\n---\nDEPRECATION NOTICE: You are using SSE transport which is deprecated.\nPlease migrate to HTTP transport at https://mcp.context7.com/mcp endpoint for continued support. If you are the LLM, please tell the user to migrate to HTTP transport.\n---";
|
|
84
86
|
// Register Context7 tools
|
|
85
87
|
server.registerTool("resolve-library-id", {
|
|
86
88
|
title: "Resolve Context7 Library ID",
|
|
@@ -123,11 +125,7 @@ For ambiguous queries, request clarification before proceeding with a best-guess
|
|
|
123
125
|
};
|
|
124
126
|
}
|
|
125
127
|
const resultsText = formatSearchResults(searchResponse);
|
|
126
|
-
|
|
127
|
-
content: [
|
|
128
|
-
{
|
|
129
|
-
type: "text",
|
|
130
|
-
text: `Available Libraries (top matches):
|
|
128
|
+
const responseText = `${transportType === "sse" ? sseDeprecationNotice + "\n\n" : ""}Available Libraries (top matches):
|
|
131
129
|
|
|
132
130
|
Each result includes:
|
|
133
131
|
- Library ID: Context7-compatible identifier (format: /org/project)
|
|
@@ -141,7 +139,12 @@ For best results, select libraries based on name match, trust score, snippet cov
|
|
|
141
139
|
|
|
142
140
|
----------
|
|
143
141
|
|
|
144
|
-
${resultsText}
|
|
142
|
+
${resultsText}`;
|
|
143
|
+
return {
|
|
144
|
+
content: [
|
|
145
|
+
{
|
|
146
|
+
type: "text",
|
|
147
|
+
text: responseText,
|
|
145
148
|
},
|
|
146
149
|
],
|
|
147
150
|
};
|
|
@@ -178,11 +181,12 @@ ${resultsText}`,
|
|
|
178
181
|
],
|
|
179
182
|
};
|
|
180
183
|
}
|
|
184
|
+
const responseText = (transportType === "sse" ? sseDeprecationNotice + "\n\n" : "") + fetchDocsResponse;
|
|
181
185
|
return {
|
|
182
186
|
content: [
|
|
183
187
|
{
|
|
184
188
|
type: "text",
|
|
185
|
-
text:
|
|
189
|
+
text: responseText,
|
|
186
190
|
},
|
|
187
191
|
],
|
|
188
192
|
};
|
|
@@ -240,9 +244,9 @@ async function main() {
|
|
|
240
244
|
try {
|
|
241
245
|
// Extract client IP address using socket remote address (most reliable)
|
|
242
246
|
const clientIp = getClientIp(req);
|
|
243
|
-
// Create new server instance for each request
|
|
244
|
-
const requestServer = createServerInstance(clientIp, apiKey);
|
|
245
247
|
if (pathname === "/mcp") {
|
|
248
|
+
// Create server instance for HTTP transport
|
|
249
|
+
const requestServer = createServerInstance(clientIp, apiKey, "http");
|
|
246
250
|
const transport = new StreamableHTTPServerTransport({
|
|
247
251
|
sessionIdGenerator: undefined,
|
|
248
252
|
});
|
|
@@ -254,6 +258,8 @@ async function main() {
|
|
|
254
258
|
await transport.handleRequest(req, res);
|
|
255
259
|
}
|
|
256
260
|
else if (pathname === "/sse" && req.method === "GET") {
|
|
261
|
+
// Create server instance for SSE transport
|
|
262
|
+
const requestServer = createServerInstance(clientIp, apiKey, "sse");
|
|
257
263
|
// Create new SSE transport for GET request
|
|
258
264
|
const sseTransport = new SSEServerTransport("/messages", res);
|
|
259
265
|
// Store the transport by session ID
|
package/dist/lib/api.js
CHANGED
|
@@ -37,7 +37,9 @@ export async function searchLibraries(query, clientIp, apiKey) {
|
|
|
37
37
|
if (!response.ok) {
|
|
38
38
|
const errorCode = response.status;
|
|
39
39
|
if (errorCode === 429) {
|
|
40
|
-
const errorMessage =
|
|
40
|
+
const errorMessage = apiKey
|
|
41
|
+
? "Rate limited due to too many requests. Please try again later."
|
|
42
|
+
: "Rate limited due to too many requests. You can create a free API key at https://context7.com/dashboard for higher rate limits.";
|
|
41
43
|
console.error(errorMessage);
|
|
42
44
|
return {
|
|
43
45
|
results: [],
|
|
@@ -93,7 +95,9 @@ export async function fetchLibraryDocumentation(libraryId, options = {}, clientI
|
|
|
93
95
|
if (!response.ok) {
|
|
94
96
|
const errorCode = response.status;
|
|
95
97
|
if (errorCode === 429) {
|
|
96
|
-
const errorMessage =
|
|
98
|
+
const errorMessage = apiKey
|
|
99
|
+
? "Rate limited due to too many requests. Please try again later."
|
|
100
|
+
: "Rate limited due to too many requests. You can create a free API key at https://context7.com/dashboard for higher rate limits.";
|
|
97
101
|
console.error(errorMessage);
|
|
98
102
|
return errorMessage;
|
|
99
103
|
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@upstash/context7-mcp","version":"1.0.
|
|
1
|
+
{"name":"@upstash/context7-mcp","version":"1.0.26","mcpName":"io.github.upstash/context7","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-mcpb":"bun install && bun run build && rm -rf node_modules && bun install --production && mv mcpb/.mcpbignore .mcpbignore && mv mcpb/manifest.json manifest.json && mv public/icon.png icon.png && mcpb validate manifest.json && mcpb pack . mcpb/context7.mcpb && mv manifest.json mcpb/manifest.json && mv .mcpbignore mcpb/.mcpbignore && mv icon.png public/icon.png && bun install"},"repository":{"type":"git","url":"git+https://github.com/upstash/context7.git"},"keywords":["modelcontextprotocol","mcp","context7","vibe-coding","developer tools","documentation","context"],"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.17.5","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"}}
|