chore: update dependencies and refactor server types to use McpServer#38
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates the project’s MCP server implementation to the newer @modelcontextprotocol/sdk API by replacing the legacy Server usage with McpServer, and updates related dependencies to match the upgraded SDK.
Changes:
- Replaced
ServerwithMcpServeracross server creation and transport entrypoints. - Updated handler/error registration to target the internal server instance (
server.server.*). - Upgraded
@modelcontextprotocol/sdkand@modelcontextprotocol/inspectorversions inpackage.json.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/server.ts | Migrates server creation to McpServer and updates handler/error wiring to the new API surface. |
| src/services/stdio.ts | Updates stdio transport entrypoint to accept McpServer. |
| src/services/sse.ts | Updates SSE transport entrypoint to accept McpServer. |
| src/services/streamable.ts | Updates streamable HTTP transport entrypoint to accept McpServer. |
| package.json | Bumps MCP SDK + inspector versions to match the migration. |
Comments suppressed due to low confidence (1)
src/server.ts:27
- The server metadata version is hard-coded to "0.1.3" here, but package.json is currently version 0.4.1. This can lead to clients/inspectors reporting the wrong server version; consider sourcing this from package.json (build-time injected) or updating it to match the package release version.
{
name: "mcp-mermaid",
version: "0.1.3",
},
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function setupToolHandlers(server: McpServer): void { | ||
| server.server.setRequestHandler(ListToolsRequestSchema, async () => ({ | ||
| tools: [tool], | ||
| })); | ||
|
|
||
| server.setRequestHandler(CallToolRequestSchema, async (request) => { | ||
| server.server.setRequestHandler(CallToolRequestSchema, async (request) => { |
There was a problem hiding this comment.
The migration to McpServer changes how request handlers and error handling are wired up (via server.server.*), but there are no automated tests covering server creation/handler registration. Adding a small unit test that instantiates createServer() and asserts ListTools/CallTool handlers are registered (and callable) would help catch SDK API regressions in future upgrades.
|
@copilot 这个重构会导致这个 mcp 运行不起来吗? |
This PR updates the MCP server implementation to align with the newer @modelcontextprotocol/sdk API by migrating from the legacy Server class to the newer McpServer.
It also upgrades related dependencies and adjusts internal server usage to ensure compatibility with the updated SDK structure.
✨ Key Changes
⚠️ Breaking Changes
🔁 Migration to McpServer
Replaced usage of Server with McpServer across the codebase
Updated server initialization:
new Server(...) → new McpServer(...)
Adjusted return types and function signatures accordingly
🔌 Handler API Updates
Updated request handler registration to use the new internal server instance:
server.setRequestHandler → server.server.setRequestHandler
Updated error handling:
server.onerror → server.server.onerror
🌐 Transport Layer Updates
Updated all transport services to accept McpServer instead of Server:
SSE (sse.ts)
STDIO (stdio.ts)
Streamable HTTP (streamable.ts)
📦 Dependency Upgrades
Upgraded MCP SDK:
@modelcontextprotocol/sdk → ^1.27.1
Upgraded inspector:
@modelcontextprotocol/inspector → ^0.21.1
🎯 Why This Change?
Ensure compatibility with the latest MCP SDK API
Adopt the new McpServer abstraction, which reflects current best practices
Fix potential issues caused by outdated handler and error APIs
Keep the project future-proof and aligned with upstream changes
The server type has changed from Server → McpServer
Internal handler registration now requires accessing server.server
Any external integrations relying on the old Server type may need updates
🧪 Testing
Verified server initialization with McpServer
Tested all transport modes:
✅ SSE
✅ STDIO
✅ Streamable HTTP
Confirmed tool registration and execution still work as expected
🧹 Additional Notes
No functional changes to Mermaid generation logic
Changes are primarily structural and compatibility-focused
✅ Checklist
Updated to latest SDK
Refactored server implementation
Updated all transports
Tested locally
Documented breaking changes