examples/server: add example MCP server with JWT and API key (#339)

This commit introduces a new example demonstrating the integration of
authentication middleware with an MCP server. The server supports both
JWT token and API key authentication, along with scope-based access
control for various MCP tools. Key features include token generation
endpoints, in-memory API key storage, and a health check endpoint.

New files added:
- `main.go`: Implements the MCP server and authentication logic.
- `go.mod` and `go.sum`: Manage dependencies for the project.
- `README.md`: Provides setup instructions, available endpoints, and
example usage.

This example serves as a reference for implementing secure access to MCP
tools.

Fixes #330
This commit is contained in:
Shusaku Yasoda 2025-09-03 00:49:46 +09:00 • committed by GitHub
commit a3935c6be2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,15 @@
module auth-middleware-example
go 1.23.0
require (
github.com/golang-jwt/jwt/v5 v5.2.2
github.com/modelcontextprotocol/go-sdk v0.3.0
)
require (
github.com/google/jsonschema-go v0.2.1-0.20250825175020-748c325cec76 // indirect
github.com/yosida95/uritemplate/v3 v3.0.2 // indirect
)
replace github.com/modelcontextprotocol/go-sdk => ../../../