Skip to content

MCP Endpoints

This page provides detailed reference for MCP (Model Context Protocol) methods supported by Seed. All MCP communication happens through the /mcp endpoint via JSON-RPC 2.0.

Overview

The MCP endpoint (POST /mcp) supports the following methods:

MethodPurposeSession Required
initializeStart new MCP sessionNo
tools/listList available toolsYes
tools/callExecute a toolYes

JSON-RPC 2.0 Format

All MCP requests and responses follow JSON-RPC 2.0 specification:

Request Format:

json
{
  "jsonrpc": "2.0",
  "method": "method_name",
  "params": { /* method parameters */ },
  "id": 1
}

Response Format (Success):

json
{
  "jsonrpc": "2.0",
  "result": { /* method result */ },
  "id": 1
}

Response Format (Error):

json
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32600,
    "message": "Error description"
  },
  "id": 1
}

initialize

Start a new MCP session - Establishes protocol version and exchanges capabilities.

Request

http
POST /mcp
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...

{
  "jsonrpc": "2.0",
  "method": "initialize",
  "params": {
    "protocolVersion": "0.1.0",
    "capabilities": {},
    "clientInfo": {
      "name": "Claude Desktop",
      "version": "1.0.0"
    }
  },
  "id": 1
}

Parameters

FieldTypeRequiredDescription
protocolVersionstringYesMCP protocol version (e.g., "0.1.0")
capabilitiesobjectYesClient capabilities (empty object for now)
clientInfoobjectNoClient metadata
clientInfo.namestringNoClient name
clientInfo.versionstringNoClient version

Response

http
HTTP/1.1 200 OK
Content-Type: application/json
mcp-session-id: 123e4567-e89b-12d3-a456-426614174000

{
  "jsonrpc": "2.0",
  "result": {
    "protocolVersion": "0.1.0",
    "capabilities": {
      "tools": {}
    },
    "serverInfo": {
      "name": "seed",
      "version": "0.1.3"
    }
  },
  "id": 1
}

Response Fields

FieldTypeDescription
protocolVersionstringMCP protocol version supported by server
capabilitiesobjectServer capabilities
capabilities.toolsobjectTool support enabled (empty object)
serverInfoobjectServer metadata
serverInfo.namestringServer name from package.json
serverInfo.versionstringServer version from package.json

Important: The response includes mcp-session-id header. Clients must include this header in all subsequent requests.

Example

javascript
const response = await fetch('https://seed.example.com/mcp', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${accessToken}`,
  },
  body: JSON.stringify({
    jsonrpc: '2.0',
    method: 'initialize',
    params: {
      protocolVersion: '0.1.0',
      capabilities: {},
      clientInfo: {
        name: 'My MCP Client',
        version: '1.0.0',
      },
    },
    id: 1,
  }),
});

const sessionId = response.headers.get('mcp-session-id');
const data = await response.json();

tools/list

List available MCP tools - Retrieves all tools registered on the server with their schemas.

Request

http
POST /mcp
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
mcp-session-id: 123e4567-e89b-12d3-a456-426614174000

{
  "jsonrpc": "2.0",
  "method": "tools/list",
  "params": {},
  "id": 2
}

Parameters

No parameters required (empty object).

Response

json
{
  "jsonrpc": "2.0",
  "result": {
    "tools": [
      {
        "name": "seed_ping",
        "description": "Ping the Seed server to test connectivity",
        "inputSchema": {
          "type": "object",
          "properties": {
            "message": {
              "type": "string",
              "description": "Optional message to include in the response"
            }
          },
          "additionalProperties": false
        }
      }
    ]
  },
  "id": 2
}

Response Fields

FieldTypeDescription
toolsarrayArray of available tools
tools[].namestringTool identifier (used in tools/call)
tools[].descriptionstringHuman-readable tool description
tools[].inputSchemaobjectJSON Schema for tool parameters

Input Schema

Each tool's inputSchema follows JSON Schema Draft 7:

json
{
  "type": "object",
  "properties": {
    "param_name": {
      "type": "string|number|boolean|object|array",
      "description": "Parameter description",
      "optional": true
    }
  },
  "required": ["required_param"],
  "additionalProperties": false
}

Example

javascript
const response = await fetch('https://seed.example.com/mcp', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${accessToken}`,
    'mcp-session-id': sessionId,
  },
  body: JSON.stringify({
    jsonrpc: '2.0',
    method: 'tools/list',
    params: {},
    id: 2,
  }),
});

const { result } = await response.json();
console.log('Available tools:', result.tools.map(t => t.name));

tools/call

Execute an MCP tool - Calls a tool with provided arguments and returns the result.

Request

http
POST /mcp
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
mcp-session-id: 123e4567-e89b-12d3-a456-426614174000

{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "seed_ping",
    "arguments": {
      "message": "Hello from Claude"
    }
  },
  "id": 3
}

Parameters

FieldTypeRequiredDescription
namestringYesTool name (from tools/list)
argumentsobjectYesTool parameters matching inputSchema

Response (Success)

json
{
  "jsonrpc": "2.0",
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Seed MCP Server: Hello from Claude"
      }
    ]
  },
  "id": 3
}

Response (Tool Error)

json
{
  "jsonrpc": "2.0",
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Error: Invalid message parameter"
      }
    ],
    "isError": true
  },
  "id": 3
}

Response Fields

FieldTypeDescription
contentarrayArray of content items
content[].typestringContent type: text, image, or resource
content[].textstringText content (if type is text)
content[].datastringBase64 image data (if type is image)
content[].mimeTypestringMIME type (if type is image)
isErrorbooleanTrue if tool execution failed (optional)

Content Types

Text Content

json
{
  "type": "text",
  "text": "Plain text or markdown content"
}

Image Content

json
{
  "type": "image",
  "data": "base64-encoded-image-data",
  "mimeType": "image/png"
}

Resource Content

json
{
  "type": "resource",
  "resource": {
    "uri": "https://example.com/resource",
    "name": "Resource Name",
    "description": "Resource description"
  }
}

Example

javascript
// Call tool
const response = await fetch('https://seed.example.com/mcp', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${accessToken}`,
    'mcp-session-id': sessionId,
  },
  body: JSON.stringify({
    jsonrpc: '2.0',
    method: 'tools/call',
    params: {
      name: 'seed_ping',
      arguments: {
        message: 'test',
      },
    },
    id: 3,
  }),
});

const { result } = await response.json();

// Check for errors
if (result.isError) {
  console.error('Tool error:', result.content[0].text);
} else {
  console.log('Tool result:', result.content[0].text);
}

Available Tools

seed_ping

Test connectivity - Ping the Seed server to verify it's responding.

Parameters:

typescript
{
  message?: string;  // Optional message to echo
}

Example:

json
{
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "name": "seed_ping",
    "arguments": {
      "message": "hello"
    }
  },
  "id": 1
}

Response:

json
{
  "jsonrpc": "2.0",
  "result": {
    "content": [
      {
        "type": "text",
        "text": "Seed MCP Server: hello"
      }
    ]
  },
  "id": 1
}

Error Handling

Protocol Errors

Invalid Request - Malformed JSON-RPC request.

json
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32600,
    "message": "Invalid Request",
    "data": {
      "details": "Missing required field: method"
    }
  },
  "id": null
}

JSON-RPC Error Codes

CodeNameDescription
-32700Parse errorInvalid JSON
-32600Invalid RequestMissing required fields
-32601Method not foundUnknown method
-32602Invalid paramsInvalid method parameters
-32603Internal errorServer error

Tool Errors

Tools can return errors in two ways:

1. Using isError flag:

json
{
  "content": [{"type": "text", "text": "Error message"}],
  "isError": true
}

2. Throwing exception (results in JSON-RPC error):

json
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32603,
    "message": "Tool execution failed",
    "data": {
      "details": "Exception message"
    }
  },
  "id": 3
}

Best Practices

Client Implementation

  1. Initialize once: Create one session per connection
  2. Store session ID: Cache for subsequent requests
  3. List tools on startup: Cache tool schemas
  4. Validate parameters: Check against inputSchema before calling
  5. Handle isError flag: Check tool-level errors
  6. Implement timeouts: Set client-side request timeouts
  7. Retry logic: Retry on network errors, not protocol errors

Tool Development

When creating new tools (see Adding MCP Tools):

  1. Use descriptive names: Tool name should be clear (e.g., get_user_info)
  2. Write clear descriptions: Help clients understand tool purpose
  3. Define schema precisely: Use JSON Schema for parameter validation
  4. Return structured content: Use appropriate content types
  5. Handle errors gracefully: Return isError for expected failures
  6. Throw for unexpected errors: Let SDK handle unexpected exceptions
  7. Test thoroughly: Write unit tests for all tools

Testing Tools

Test seed_ping

bash
# Initialize session
SESSION_ID=$(curl -s -X POST https://seed.example.com/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $JWT_TOKEN" \
  -d '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"0.1.0","capabilities":{}},"id":1}' \
  | grep -o 'mcp-session-id: [^"]*' | cut -d' ' -f2)

# Call ping tool
curl -X POST https://seed.example.com/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $JWT_TOKEN" \
  -H "mcp-session-id: $SESSION_ID" \
  -d '{
    "jsonrpc": "2.0",
    "method": "tools/call",
    "params": {
      "name": "seed_ping",
      "arguments": {"message": "test"}
    },
    "id": 2
  }'

Future Methods

The following MCP methods are planned but not yet implemented:

  • resources/list - List available resources
  • resources/read - Read resource content
  • prompts/list - List available prompts
  • prompts/get - Get prompt template
  • sampling/createMessage - Request LLM completion

Released under the MIT License.