Skip to content

Example from readme incorrect #7

@harrismcc

Description

@harrismcc

When running the exact example from the README:

import { CodeModeUtcpClient } from '@utcp/code-mode';

const client = await CodeModeUtcpClient.create();

// Connect to GitHub MCP server
await client.registerManual({
  name: 'github',
  call_template_type: 'mcp',
  config: {
    mcpServers: {
      github: {
        command: 'docker',
        args: ['run', '-i', '--rm', '-e', 'GITHUB_PERSONAL_ACCESS_TOKEN', 'mcp/github'],
        env: { GITHUB_PERSONAL_ACCESS_TOKEN: process.env.GITHUB_TOKEN }
      }
    }
  }
});

I get an error:

Zod validation failed for call template 'github' after variable substitution. [
  {
    code: "custom",
    message: "Invalid CallTemplate object",
    fatal: true,
    path: [],
  }
]
1554 |   async substituteCallTemplateVariables(callTemplate, namespace) {
1555 |     const rawSubstituted = await this.variableSubstitutor.substitute(callTemplate, this.config, namespace);
1556 |     const result = CallTemplateSchema.safeParse(rawSubstituted);
1557 |     if (!result.success) {
1558 |       console.error(`Zod validation failed for call template '${callTemplate.name}' after variable substitution.`, result.error.issues);
1559 |       throw new Error(`Invalid call template after variable substitution: ${result.error.message}`);
                       ^
error: Invalid call template after variable substitution: [
  {
    "code": "custom",
    "message": "Invalid CallTemplate object",
    "fatal": true,
    "path": []
  }
]
      at substituteCallTemplateVariables (/Users/harris/Documents/slack-buddy/node_modules/@utcp/sdk/dist/index.js:1559:17)
      at async registerManual (/Users/harris/Documents/slack-buddy/node_modules/@utcp/sdk/dist/index.js:1381:46)

This is fixed by installing the @utcp/mcp package and modifying the example to be:

// Added import of @utcp/mcp
import "@utcp/mcp";
import { CodeModeUtcpClient } from '@utcp/code-mode';

const client = await CodeModeUtcpClient.create();

// Connect to GitHub MCP server
await client.registerManual({
  name: 'github',
  call_template_type: 'mcp',
  config: {
    mcpServers: {
      github: {
        transport: "stdio", // Transport is required
        command: 'docker',
        args: ['run', '-i', '--rm', '-e', 'GITHUB_PERSONAL_ACCESS_TOKEN', 'mcp/github'],
        env: { GITHUB_PERSONAL_ACCESS_TOKEN: process.env.GITHUB_TOKEN }
      }
    }
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions