Skip to content

Commit 190b79f

Browse files
authored
Merge branch 'main' into patch-1
2 parents 91bac3c + ea35591 commit 190b79f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ A growing set of community-developed and maintained servers demonstrates various
104104
- **[MongoDB](https://github.com/kiliczsh/mcp-mongo-server)** - A Model Context Protocol Server for MongoDB.
105105
- **[Airtable](https://github.com/felores/airtable-mcp)** - Airtable Model Context Protocol Server.
106106
- **[Google Tasks](https://github.com/zcaceres/gtasks-mcp)** - Google Tasks API Model Context Protocol Server.
107+
- **[Fetch](https://github.com/zcaceres/fetch-mcp)** - A server that flexibly fetches HTML, JSON, Markdown, or plaintext
107108

108109
## 📚 Resources
109110

src/everything/everything.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
22
import {
33
CallToolRequestSchema,
4+
CompleteRequestSchema,
45
CreateMessageRequest,
56
CreateMessageResultSchema,
67
GetPromptRequestSchema,
@@ -50,6 +51,13 @@ const SampleLLMSchema = z.object({
5051
.describe("Maximum number of tokens to generate"),
5152
});
5253

54+
// Example completion values
55+
const EXAMPLE_COMPLETIONS = {
56+
style: ["casual", "formal", "technical", "friendly"],
57+
temperature: ["0", "0.5", "0.7", "1.0"],
58+
resourceId: ["1", "2", "3", "4", "5"],
59+
};
60+
5361
const GetTinyImageSchema = z.object({});
5462

5563
enum ToolName {
@@ -431,6 +439,34 @@ export const createServer = () => {
431439
throw new Error(`Unknown tool: ${name}`);
432440
});
433441

442+
server.setRequestHandler(CompleteRequestSchema, async (request) => {
443+
const { ref, argument } = request.params;
444+
445+
if (ref.type === "ref/resource") {
446+
const resourceId = ref.uri.split("/").pop();
447+
if (!resourceId) return { completion: { values: [] } };
448+
449+
// Filter resource IDs that start with the input value
450+
const values = EXAMPLE_COMPLETIONS.resourceId.filter(id =>
451+
id.startsWith(argument.value)
452+
);
453+
return { completion: { values, hasMore: false, total: values.length } };
454+
}
455+
456+
if (ref.type === "ref/prompt") {
457+
// Handle completion for prompt arguments
458+
const completions = EXAMPLE_COMPLETIONS[argument.name as keyof typeof EXAMPLE_COMPLETIONS];
459+
if (!completions) return { completion: { values: [] } };
460+
461+
const values = completions.filter(value =>
462+
value.startsWith(argument.value)
463+
);
464+
return { completion: { values, hasMore: false, total: values.length } };
465+
}
466+
467+
throw new Error(`Unknown reference type`);
468+
});
469+
434470
server.setRequestHandler(SetLevelRequestSchema, async (request) => {
435471
const { level } = request.params;
436472

0 commit comments

Comments
 (0)