From 1eca8f86260596c6daaf29d3be872eb02721c15c Mon Sep 17 00:00:00 2001 From: Ashwin Bhat Date: Tue, 17 Dec 2024 14:22:15 -0800 Subject: [PATCH 1/2] add completion examples to everything server --- src/everything/everything.ts | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/everything/everything.ts b/src/everything/everything.ts index a31cd7f0..47d9d99e 100644 --- a/src/everything/everything.ts +++ b/src/everything/everything.ts @@ -1,6 +1,7 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js"; import { CallToolRequestSchema, + CompleteRequestSchema, CreateMessageRequest, CreateMessageResultSchema, GetPromptRequestSchema, @@ -48,6 +49,13 @@ const SampleLLMSchema = z.object({ .describe("Maximum number of tokens to generate"), }); +// Example completion values +const EXAMPLE_COMPLETIONS = { + style: ["casual", "formal", "technical", "friendly"], + temperature: ["0", "0.5", "0.7", "1.0"], + resourceId: ["1", "2", "3", "4", "5"], +}; + const GetTinyImageSchema = z.object({}); enum ToolName { @@ -412,6 +420,34 @@ export const createServer = () => { throw new Error(`Unknown tool: ${name}`); }); + server.setRequestHandler(CompleteRequestSchema, async (request) => { + const { ref, argument } = request.params; + + if (ref.type === "ref/resource") { + const resourceId = ref.uri.split("/").pop(); + if (!resourceId) return { completion: { values: [] } }; + + // Filter resource IDs that start with the input value + const values = EXAMPLE_COMPLETIONS.resourceId.filter(id => + id.startsWith(argument.value) + ); + return { completion: { values, hasMore: false, total: values.length } }; + } + + if (ref.type === "ref/prompt") { + // Handle completion for prompt arguments + const completions = EXAMPLE_COMPLETIONS[argument.name as keyof typeof EXAMPLE_COMPLETIONS]; + if (!completions) return { completion: { values: [] } }; + + const values = completions.filter(value => + value.startsWith(argument.value) + ); + return { completion: { values, hasMore: false, total: values.length } }; + } + + throw new Error(`Unknown reference type`); + }); + server.setRequestHandler(SetLevelRequestSchema, async (request) => { const { level } = request.params; From 423579ff9f994f25730236f30ab3345c6aacb08e Mon Sep 17 00:00:00 2001 From: Zach Caceres Date: Tue, 17 Dec 2024 18:08:07 -0700 Subject: [PATCH 2/2] Update README.md Add flexible fetch server (in node) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 916e2d5d..7d828c06 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ A growing set of community-developed and maintained servers demonstrates various - **[TMDB](https://github.com/Laksh-star/mcp-server-tmdb)** - This MCP server integrates with The Movie Database (TMDB) API to provide movie information, search capabilities, and recommendations. - **[MongoDB](https://github.com/kiliczsh/mcp-mongo-server)** - A Model Context Protocol Server for MongoDB. - **[Airtable](https://github.com/felores/airtable-mcp)** - Airtable Model Context Protocol Server. +- **[Fetch](https://github.com/zcaceres/fetch-mcp)** - A server that flexibly fetches HTML, JSON, Markdown, or plaintext ## 📚 Resources