mcp-rest
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

MCP REST Bridge

The MCP REST Bridge allows you to expose any OpenAPI endpoint through the MCP protocol without additional coding or testing. Your existing REST API can be seamlessly accessed by AI tools like Anthropic, Cursor, and Windsurf via MCP.

Core functionality

  • sse/stdio transports
  • OpenAPI authentication via headers
  • Including and excluding paths from the API
  • Custom base url for accessing API

Local usage

1. Install mcp-rest

npm install mcp-rest

2. Running MCP server

sse mode

npx mcp-rest \
    --mode sse \
    --api-spec-url "https://api.example.com/v1/openapi.json" 

stdio mode

npx mcp-rest \
    --mode stdio \
    --api-spec-url "https://api.example.com/v1/openapi.json" 

Configuration

Configuration can be provided via environment variables or command line arguments. Environment variables take precedence over command line arguments.

The REST Bridge supports filtering which endpoints from the OpenAPI specification will be exposed as MCP tools, allowing you to control access to specific API endpoints based on your needs.

Environment Variable Command Line Argument Description
MODE --mode Run mode (sse or stdio), required
API_SPEC_URL --api-spec-url URL of the OpenAPI specification, required
API_BASE_URL --api-base-url Base URL for API requests
INCLUDE_ENDPOINTS --include-endpoints Comma-separated list of endpoints to include. Format <PATH>:<METHOD>. Wildcard is supported in match all paths for a method *:GET or all methods for a path /user/{id}:*
EXCLUDE_ENDPOINTS --exclude-endpoints Comma-separated list of endpoints to exclude. Same format as include endpoints.
AUTHENTICATION --authentication Authentication in format <type>:<value> where type is one of: Api-Key, X-Api-Key, Bearer, JWT, or Basic

NOTE: when using --include-endpoints and --exclude-endpoints, first included endpoints are added to candidates list and then excluded endpoints will be removed from the candidates list.

Development details

TODO

  • [ ] - Serve binary content
  • [ ] - Improve test coverage
  • [ ] - Configure endpoints to be exposed as resources
  • [ ] - File-based extended configuration

Readme

Keywords

Package Sidebar

Install

npm i mcp-rest

Weekly Downloads

6

Version

0.1.1

License

MIT

Unpacked Size

46.2 kB

Total Files

23

Last publish

Collaborators

  • bonya1980