Skip to content

Fix: Update project for current MCP SDK and OpenCode configuration format - #5

Open
amda-phd wants to merge 7 commits into
TheArchitectit:masterfrom
amda-phd:fix/tsconfig-module-resolution
Open

Fix: Update project for current MCP SDK and OpenCode configuration format#5
amda-phd wants to merge 7 commits into
TheArchitectit:masterfrom
amda-phd:fix/tsconfig-module-resolution

Conversation

@amda-phd

Copy link
Copy Markdown

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.json had incompatible settings: moduleResolution: "Bundler" with module: "Node16"
  • Multiple TypeScript errors in source files (undefined variables, type mismatches, missing function calls)

2. SDK API changes

  • The @modelcontextprotocol/sdk API has changed significantly since the code was written
  • Server class with addTool() method no longer exists - replaced with McpServer and registerTool()
  • Import paths changed (e.g., stdio moved to server/stdio.js)

3. ESM compatibility issues

  • index.ts only exported functions but didn't start the server, so node dist/index.js did nothing
  • __dirname is not available in ES modules
  • require.main === module doesn't work in ESM

4. Outdated documentation

  • README used old OpenCode config format (mcpServers instead of mcp)
  • Missing type: "local" in config
  • Used slash commands (/list_skills) which no longer work in OpenCode - tools are now invoked via natural language
  • Wrong config file path (~/.config/opencode/config.json instead of opencode.json)

Changes Made

  • tsconfig.json: Fixed moduleResolution to match module setting
  • server.ts: Migrated to MCP SDK v1.29 API (McpServer, registerTool), updated imports
  • skill-manager.ts: Fixed TypeScript errors (function calls, variable scoping, type narrowing)
  • config.ts: Added ESM-compatible __dirname using import.meta.url, handle undefined HOME env var
  • index.ts: Added server initialization code to actually start the MCP server
  • README.md: Updated configuration examples to use current OpenCode mcp format and natural language usage examples

Testing

After these changes, the server builds successfully, starts properly, and responds to MCP protocol messages:

npm install  # Now completes without errors
node dist/index.js  # Server starts and accepts connections

The MCP server now works as documented and can be used with OpenCode.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +41 to 51
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 }] };
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

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 }] };
    }
  );

@amda-phd amda-phd Jun 12, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread opencode-skills-mcp-server-ts/src/config.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant