Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
zcaceres authored Dec 19, 2024
2 parents 91bac3c + ea35591 commit 190b79f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ A growing set of community-developed and maintained servers demonstrates various
- **[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.
- **[Google Tasks](https://github.com/zcaceres/gtasks-mcp)** - Google Tasks API Model Context Protocol Server.
- **[Fetch](https://github.com/zcaceres/fetch-mcp)** - A server that flexibly fetches HTML, JSON, Markdown, or plaintext

## 📚 Resources

Expand Down
36 changes: 36 additions & 0 deletions src/everything/everything.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import {
CallToolRequestSchema,
CompleteRequestSchema,
CreateMessageRequest,
CreateMessageResultSchema,
GetPromptRequestSchema,
Expand Down Expand Up @@ -50,6 +51,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 {
Expand Down Expand Up @@ -431,6 +439,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;

Expand Down

0 comments on commit 190b79f

Please sign in to comment.