mirror of
https://github.com/modelcontextprotocol/servers.git
synced 2026-04-25 23:35:27 +02:00
Refactor servers to use registerTool/registerResource/registerPrompt APIs
Updated all TypeScript MCP servers to use the new registration API pattern: - Replaced setRequestHandler(ListToolsRequestSchema) with registerTool() - Replaced setRequestHandler(GetPromptRequestSchema) with registerPrompt() - Replaced setRequestHandler(ReadResourceRequestSchema) with registerResource() Changes: - sequentialthinking: Migrated 1 tool to registerTool() - memory: Migrated 9 tools to registerTool() - filesystem: Migrated 14 tools to registerTool() - everything: Migrated 11 tools, 3 prompts, and 100 resources to new APIs Also updated SDK versions to ^1.20.1 across all servers for consistency. Note: These APIs are not yet available in the current SDK version. This is preparatory work for when the SDK is updated to support these methods. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -3,8 +3,6 @@
|
||||
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||
import {
|
||||
CallToolRequestSchema,
|
||||
ListToolsRequestSchema,
|
||||
Tool,
|
||||
} from "@modelcontextprotocol/sdk/types.js";
|
||||
// Fixed chalk import for ESM
|
||||
@@ -255,22 +253,13 @@ const server = new Server(
|
||||
|
||||
const thinkingServer = new SequentialThinkingServer();
|
||||
|
||||
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
||||
tools: [SEQUENTIAL_THINKING_TOOL],
|
||||
}));
|
||||
|
||||
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
if (request.params.name === "sequentialthinking") {
|
||||
return thinkingServer.processThought(request.params.arguments);
|
||||
server.registerTool({
|
||||
name: SEQUENTIAL_THINKING_TOOL.name,
|
||||
description: SEQUENTIAL_THINKING_TOOL.description,
|
||||
inputSchema: SEQUENTIAL_THINKING_TOOL.inputSchema,
|
||||
handler: async (args) => {
|
||||
return thinkingServer.processThought(args);
|
||||
}
|
||||
|
||||
return {
|
||||
content: [{
|
||||
type: "text",
|
||||
text: `Unknown tool: ${request.params.name}`
|
||||
}],
|
||||
isError: true
|
||||
};
|
||||
});
|
||||
|
||||
async function runServer() {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"watch": "tsc --watch"
|
||||
},
|
||||
"dependencies": {
|
||||
"@modelcontextprotocol/sdk": "0.5.0",
|
||||
"@modelcontextprotocol/sdk": "^1.20.1",
|
||||
"chalk": "^5.3.0",
|
||||
"yargs": "^17.7.2"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user