Wrap any existing Echo API into MCP tools, enabling AI agents to interact with your API through Model Context Protocol. Inspired by gin-mcp but for the Echo framework. - Zero Configuration: Works with any existing Echo API - Multiple Schema Sources: Support for Swaggo, raw OpenAPI YAML/JSON, and manual schemas - Filtering: Include/exclude endpoints with wildcard patterns - MCP Compatible: Works wi
Add this skill
npx mdskills install BrunoKrugel/echo-mcpTransforms Echo APIs into MCP-compatible tools with multiple schema sources and flexible endpoint filtering
1# MCP Wrapper for Echo Framework23[](https://github.com/features/actions)4[](https://codecov.io/gh/BrunoKrugel/echo-mcp)5[](https://goreportcard.com/report/github.com/BrunoKrugel/echo-mcp)6[](https://github.com/BrunoKrugel/echo-mcp/releases)78Wrap any existing Echo API into MCP tools, enabling AI agents to interact with your API through [Model Context Protocol](https://modelcontextprotocol.io/introduction).910Inspired by [gin-mcp](https://github.com/ckanthony/gin-mcp) but for the [Echo framework](https://echo.labstack.com/).1112## Key Features1314- **Zero Configuration**: Works with any existing Echo API15- **Multiple Schema Sources**: Support for Swaggo, raw OpenAPI YAML/JSON, and manual schemas16- **Filtering**: Include/exclude endpoints with wildcard patterns17- **MCP Compatible**: Works with any agent that supports MCP.1819## Installation2021```bash22go get github.com/BrunoKrugel/echo-mcp23```2425## Quick Start2627```go28package main2930import (31 "net/http"32 server "github.com/BrunoKrugel/echo-mcp"33 "github.com/labstack/echo/v4"34)3536func main() {37 e := echo.New()3839 // Existing API routes40 e.GET("/ping", func(c echo.Context) error {41 return c.JSON(http.StatusOK, map[string]string{"message": "pong"})42 })434445 // Add MCP support46 mcp := server.New(e)47 mcp.Mount("/mcp")4849 e.Start(":8080")50}51```5253Now the API is accessible at `http://localhost:8080/mcp`5455## Advanced Usage5657### Automatic Swagger Schemas5859If you already use Swaggo for Swagger documentation, enable automatic schema generation:6061```go62// @Summary Get user by ID63// @Description Retrieve detailed user information64// @Tags users65// @Param id path int true "User ID" minimum(1)66// @Success 200 {object} User67// @Router /users/{id} [get]68func GetUser(c echo.Context) error {69 // Your handler code70}7172func main() {73 e := echo.New()74 e.GET("/users/:id", GetUser)7576 // Enable automatic swagger schema generation77 mcp := server.NewWithConfig(e, &server.Config{78 BaseURL: "http://localhost:8080",79 EnableSwaggerSchemas: true,80 })81 mcp.Mount("/mcp")8283 e.Start(":8080")84}85```8687### Raw OpenAPI Schema Support8889If you use other OpenAPI libraries like `swaggest/openapi-go`, you can pass a raw YAML or JSON schema string:9091```go92import (93 "github.com/swaggest/openapi-go/openapi3"94 server "github.com/BrunoKrugel/echo-mcp"95)9697func main() {98 e := echo.New()99100 // ... define your routes ...101102 // Generate OpenAPI schema103 reflector := openapi3.Reflector{}104 reflector.SpecEns().WithOpenapi("3.0.3")105 reflector.SpecEns().Info.WithTitle("My API").WithVersion("1.0.0")106107 // Add operations to reflector108 // ...109110 // Export to YAML (or JSON)111 schema, _ := reflector.Spec.MarshalYAML()112113 // Pass raw schema to MCP server114 // ... you can also embed the schema from an exiting openapi.yaml file115 mcp := server.NewWithConfig(e, &server.Config{116 OpenAPISchema: string(schema),117 })118 mcp.Mount("/mcp")119120 e.Start(":8080")121}122```123124The `OpenAPISchema` field accepts both YAML and JSON formatted strings. When provided, it automatically populates:125- Server name from schema title126- Description from schema description127- Version from schema version128- Tool schemas from operation definitions129130### Endpoint Filtering131132Expose only the necessary endpoints to MCP tools:133134```go135mcp := server.New(e)136137// Include only specific endpoints138mcp.RegisterEndpoints([]string{139 "/api/v1/users/:id",140 "/api/v1/orders",141})142143// Or exclude internal endpoints144mcp.ExcludeEndpoints([]string{145 "/health", // Exclude health checks146})147```148149### Manual Schema Registration (WIP)150151For better control, register schemas manually:152153```go154type CreateUserRequest struct {155 Name string `json:"name" jsonschema:"required,description=User full name"`156 Email string `json:"email" jsonschema:"required,description=User email address"`157 Age int `json:"age,omitempty" jsonschema:"minimum=0,maximum=150"`158}159160type UserQuery struct {161 Page int `form:"page,default=1" jsonschema:"minimum=1"`162 Limit int `form:"limit,default=10" jsonschema:"maximum=100"`163 Active bool `form:"active" jsonschema:"description=Filter by active status"`164}165166mcp := server.New(e, &server.Config{BaseURL: "http://localhost:8080"})167168// Register schemas for specific routes169mcp.RegisterSchema("POST", "/users", nil, CreateUserRequest{})170mcp.RegisterSchema("GET", "/users", UserQuery{}, nil)171```172173## Schema Generation Methods174175Echo-MCP supports four schema generation approaches, with automatic fallback:176177| Method | Use Case | Priority |178|--------|----------|----------|179| **Raw OpenAPI Schema** | Using OpenAPI libraries like swaggest/openapi-go | First (if OpenAPISchema is set) |180| **Swagger** | Production APIs with Swaggo annotations | First (if EnableSwaggerSchemas is set) |181| **Manual** | Fine-grained control, complex validation | Second |182| **Automatic** | Quick prototyping, simple endpoints | Fallback |183184```go185// Option 1: Using raw OpenAPI schema (swaggest/openapi-go, etc.)186schema, _ := reflector.Spec.MarshalYAML()187mcp := server.New(e, &server.Config{188 OpenAPISchema: string(schema), // Use raw schema189})190191// Option 2: Using Swaggo192mcp := server.New(e, &server.Config{193 EnableSwaggerSchemas: true, // Load from swaggo docs194})195196// Option 3: Manual schemas for fine-grained control197mcp.RegisterSchema("POST", "/users", nil, CreateUserRequest{})198199// Option 4: Automatic inference (fallback)200// No configuration needed - routes will use basic path/body inference201```202203## MCP Client Integration204205Once your server is running:206207### Manual configuration208209```json210{211 "mcpServers": {212 "echo-api": {213 "type": "http",214 "url": "http://localhost:8080/mcp",215 "timeout": 120216 },217 }218}219```220221## Local Testing222223For local testing, use MCP Inspector:224225```bash226npx @modelcontextprotocol/inspector http://localhost:8080/mcp227```228229## Acknowledgments230231- [Swaggo](https://github.com/swaggo/swag) - Swagger documentation generator232- [swaggest/openapi-go](https://github.com/swaggest/openapi-go) - OpenAPI 3.0 toolkit for Go233- [Echo Framework](https://echo.labstack.com/) - High performance Go web framework234- [Echo Swagger](https://github.com/swaggo/echo-swagger) - Swagger UI middleware for Echo235- [Model Context Protocol](https://modelcontextprotocol.io/) - Universal protocol for AI-tool interaction236
Full transparency — inspect the skill content before installing.