Fix: Update project for current MCP SDK and OpenCode configuration format - #5
Fix: Update project for current MCP SDK and OpenCode configuration format#5amda-phd wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request migrates the MCP server to the newer @modelcontextprotocol/sdk package, updates the configuration format in the README, and introduces ESM compatibility fixes. It also adds proper TypeScript interfaces and fixes a bug in directory copying. However, the migration to McpServer incorrectly uses registerTool instead of the correct tool method, which will cause compilation and runtime errors. Additionally, falling back to an empty string when the user's home directory is undefined can result in unexpected relative paths for global installations, so throwing an explicit error is recommended.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| server.registerTool('list_skills', { | ||
| description: 'List all available OpenCode skills with optional filtering by category or depth. Shows installation status.', | ||
| inputSchema: z.object({ | ||
| inputSchema: { | ||
| category: z.string().optional().describe('Filter by skill category (e.g., \'Development\', \'Writing\', \'Document Processing\')'), | ||
| depth: z.string().optional().describe('Filter by depth (e.g., \'Comprehensive\', \'Standard\', \'Quick Reference\')'), | ||
| installed_only: z.boolean().optional().default(false).describe('Only show installed skills'), | ||
| }).strict(), | ||
| }, | ||
| }, async ({ category, depth, installed_only }) => { | ||
| const result = await listSkills({ category, depth, installedOnly: installed_only }); | ||
| return { content: [{ type: 'text', text: result }] }; | ||
| }); |
There was a problem hiding this comment.
The @modelcontextprotocol/sdk (v1.0.0+) McpServer class does not have a registerTool method. Instead, it uses the tool method. Additionally, the tool method expects the schema shape directly as the third argument, rather than wrapped in an inputSchema object.
Using registerTool will result in a TypeScript compilation error and a runtime TypeError.
Please update all tool registrations to use the correct server.tool API. Here is an example for list_skills:
server.tool(
'list_skills',
'List all available OpenCode skills with optional filtering by category or depth. Shows installation status.',
{
category: z.string().optional().describe("Filter by skill category (e.g., 'Development', 'Writing', 'Document Processing')"),
depth: z.string().optional().describe("Filter by depth (e.g., 'Comprehensive', 'Standard', 'Quick Reference')"),
installed_only: z.boolean().optional().default(false).describe('Only show installed skills'),
},
async ({ category, depth, installed_only }) => {
const result = await listSkills({ category, depth, installedOnly: installed_only });
return { content: [{ type: 'text', text: result }] };
}
);There was a problem hiding this comment.
The SDK v1.29.0 (which is what ^1.0.0 resolves to) actually has both methods, but tool() is marked as @deprecated Use registerTool instead. So registerTool is the correct, non-deprecated API.
From the SDK type definitions:
/** @deprecated Use `registerTool` instead. */
tool<Args extends ZodRawShapeCompat>(...): RegisteredTool;
registerTool<...>(name: string, config: {...}, cb: ToolCallback): RegisteredTool;
The code compiles and runs successfully with registerTool. The example in the review using server.tool() would actually use a deprecated API.
Description
I tried to follow the README instructions to install and use this MCP server with
npm install, but encountered multiple issues that prevented the server from working. After investigating, I discovered the project was outdated compared to the current MCP SDK API and OpenCode configuration format.Issues Found
1. Build failures
tsconfig.jsonhad incompatible settings:moduleResolution: "Bundler"withmodule: "Node16"2. SDK API changes
@modelcontextprotocol/sdkAPI has changed significantly since the code was writtenServerclass withaddTool()method no longer exists - replaced withMcpServerandregisterTool()stdiomoved toserver/stdio.js)3. ESM compatibility issues
index.tsonly exported functions but didn't start the server, sonode dist/index.jsdid nothing__dirnameis not available in ES modulesrequire.main === moduledoesn't work in ESM4. Outdated documentation
mcpServersinstead ofmcp)type: "local"in config/list_skills) which no longer work in OpenCode - tools are now invoked via natural language~/.config/opencode/config.jsoninstead ofopencode.json)Changes Made
moduleResolutionto matchmodulesettingMcpServer,registerTool), updated imports__dirnameusingimport.meta.url, handle undefinedHOMEenv varmcpformat and natural language usage examplesTesting
After these changes, the server builds successfully, starts properly, and responds to MCP protocol messages:
The MCP server now works as documented and can be used with OpenCode.