Skip to main content
Goose extensions communicate using MCP (Model Context Protocol), a standardized protocol for AI agent-extension communication.

What is MCP?

MCP (Model Context Protocol) is an open protocol that enables AI applications to integrate with external data sources and tools. It provides:
  • Standardized communication - Consistent interface across extensions
  • Tool discovery - Extensions expose available capabilities
  • Bidirectional streaming - Efficient data transfer
  • Type safety - JSON Schema validation

Protocol Overview

MCP uses JSON-RPC 2.0 over stdio (standard input/output) for communication.

Message Format

Requests:
Responses:
Errors:

Core MCP Methods

Tools

List Tools
Call Tool

Resources

List Resources
Read Resource

Prompts

List Prompts
Get Prompt

MCP in Goose

Goose uses the rmcp crate for MCP implementation.

Server Implementation

Implement the ServerHandler trait:

Serving the Extension

Stdio transport:
In-process (for builtin extensions):

Extension Manager

Goose’s ExtensionManager handles MCP communication:

Testing MCP Extensions

MCP Inspector

Use the official MCP Inspector to test extensions:
For external extensions:

Integration Tests

Record and replay MCP interactions (crates/goose/tests/mcp_integration_test.rs):
Record interactions:

Error Handling

Standard Error Codes

  • -32700 - Parse error
  • -32600 - Invalid request
  • -32601 - Method not found
  • -32602 - Invalid params
  • -32603 - Internal error

Custom Errors

Transport Layer

MCP supports multiple transports:

Stdio (Standard)

Communication over stdin/stdout:

Duplex Stream (Builtin Extensions)

In-process communication:

Best Practices

1. Input Validation

Validate all inputs using JSON Schema:

2. Clear Descriptions

Provide detailed descriptions:

3. Error Reporting

Return actionable error messages:

4. Timeouts

Implement timeouts for long operations:

MCP Resources

Next Steps