MCP REST Server

by gyuco

Not rated
GitHub

About

A server for interacting with REST APIs, featuring authentication and Swagger documentation support.

Details

Author
gyuco
Categories
Developer Tools, API, Knowledge Base

Configuration Methods (in order of priority)

- Command Line Arguments(highest priority) - Environment Variables - Configuration File - Manual Configuration(via MCP tools - lowest priority)

Option 1: Auto-Configuration with Environment Variables (Recommended)

{ "mcpServers": { "mcp-rest-github": { "command": "node", "args": ["/path/to/your/mcp-rest/dist/index.js"], "env": { "MCP_REST_BASE_URL": "https://api.github.com", "MCP_REST_AUTH_TYPE": "token", "MCP_REST_TOKEN": "your-github-token-here", "MCP_REST_SWAGGER_URL": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json" } }, "mcp-rest-petstore": { "command": "node", "args": ["/path/to/your/mcp-rest/dist/index.js"], "env": { "MCP_REST_BASE_URL": "https://petstore.swagger.io/v2", "MCP_REST_AUTH_TYPE": "token", "MCP_REST_TOKEN": "your-api-key", "MCP_REST_SWAGGER_URL": "https://petstore.swagger.io/v2/swagger.json" } } } }

A Model Context Protocol (MCP) server that provides REST API client functionality with authentication support and Swagger documentation integration.

- Multiple Authentication Methods: Support for both token-based and login-based authentication
- Swagger Integration: Automatic endpoint discovery and documentation from OpenAPI/Swagger specs
- Automatic Token Management: Handles token refresh and re-authentication
- Comprehensive HTTP Methods: Support for GET, POST, PUT, DELETE, and PATCH requests
- Error Handling: Robust error handling with retry logic
- MCP Compatible: Fully compatible with the Model Context Protocol

The server supports two authentication methods:

{ "baseUrl": "https://api.example.com", "swaggerUrl": "https://api.example.com/swagger.json", "auth": { "type": "token", "token": "your-api-token-here" }, "timeout": 30000, "retries": 3 }
{ "baseUrl": "https://api.example.com", "swaggerUrl": "https://api.example.com/swagger.json", "auth": { "type": "login", "username": "your-username", "password": "your-password", "loginEndpoint": "/auth/login", "tokenField": "access_token" }, "timeout": 30000, "retries": 3 }

Configure the REST client with authentication and API details.

- baseUrl(required): Base URL for the REST API
- auth(required): Authentication configuration (token or login)
- swaggerUrl(optional): URL to Swagger/OpenAPI documentation
- timeout(optional): Request timeout in milliseconds (default: 30000)
- retries(optional): Number of retries for failed requests (default: 3)

Make HTTP requests to the configured API.

- method(required): HTTP method (GET, POST, PUT, DELETE, PATCH)
- path(required): API endpoint path
- params(optional): Query parameters or request body parameters
- body(optional): Request body for POST, PUT, PATCH requests
- headers(optional): Additional headers

Get the complete list of available endpoints from Swagger documentation.

Search for endpoints in the Swagger documentation.

- query(required): Search query to find matching endpoints

Get detailed information about a specific endpoint.

- path(required): Endpoint path
- method(required): HTTP method

Check if the client is currently authenticated.

{ "baseUrl": "https://jsonplaceholder.typicode.com", "auth": { "type": "token", "token": "dummy-token" } }
{ "method": "GET", "path": "/posts/1" }
{ "method": "POST", "path": "/posts", "body": { "title": "New Post", "body": "Post content", "userId": 1 } }
{ "baseUrl": "https://petstore.swagger.io/v2", "swaggerUrl": "https://petstore.swagger.io/v2/swagger.json", "auth": { "type": "token", "token": "your-api-key" } }

- Search endpoints:search_endpointswith query "pet"
- Get endpoint info:get_endpoint_infowith path "/pet" and method "POST"
- View all documentation:get_swagger_documentation
- Token is stored and used immediately
- Added to requests asAuthorization: Bearer <token>
- If 401 received, no automatic retry (token assumed invalid)
- Makes login request to specified endpoint
- Extracts token from response usingtokenField
- Stores token in memory
- Adds token to subsequent requests
- If 401 received, automatically re-authenticates and retries

- Network errors: Automatic retry with exponential backoff
- Authentication errors: Automatic re-authentication for login-based auth
- Validation errors: Clear error messages with details
- API errors: HTTP status and error message forwarding

src/ ├── types.ts # TypeScript type definitions ├── auth.ts # Authentication manager ├── swagger.ts # Swagger documentation parser ├── rest-client.ts # REST client implementation └── index.ts # MCP server implementation

The MCP REST server now supportsautomatic configurationthrough multiple methods, eliminating the need to configure APIs manually for each project.

Configuration Methods (in order of priority)

- Command Line Arguments(highest priority) - Environment Variables - Configuration File - Manual Configuration(via MCP tools - lowest priority)

Option 1: Auto-Configuration with Environment Variables (Recommended)

{ "mcpServers": { "mcp-rest-github": { "command": "node", "args": ["/path/to/your/mcp-rest/dist/index.js"], "env": { "MCP_REST_BASE_URL": "https://api.github.com", "MCP_REST_AUTH_TYPE": "token", "MCP_REST_TOKEN": "your-github-token-here", "MCP_REST_SWAGGER_URL": "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json" } }, "mcp-rest-petstore": { "command": "node", "args": ["/path/to/your/mcp-rest/dist/index.js"], "env": { "MCP_REST_BASE_URL": "https://petstore.swagger.io/v2", "MCP_REST_AUTH_TYPE": "token", "MCP_REST_TOKEN": "your-api-key", "MCP_REST_SWAGGER_URL": "https://petstore.swagger.io/v2/swagger.json" } } } }

Option 2: Auto-Configuration with Config Files

{ "mcpServers": { "mcp-rest-github": { "command": "node", "args": ["/path/to/your/mcp-rest/dist/index.js", "--config", "/path/to/your/mcp-rest/examples/github-api.json"] }, "mcp-rest-petstore": { "command": "node", "args": ["/path/to/your/mcp-rest/dist/index.js", "--config", "/path/to/your/mcp-rest/examples/petstore.json"] } } }

Option 3: Auto-Configuration with Command Line Arguments

{ "mcpServers": { "mcp-rest-github": { "command": "node", "args": [ "/path/to/your/mcp-rest/dist/index.js", "--base-url", "https://api.github.com", "--auth-type", "token", "--token", "your-github-token-here", "--swagger-url", "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json" ] } } }

- macOS:~/Library/Application Support/Claude/claude_desktop_config.json
- Windows:%APPDATA%\Claude\claude_desktop_config.json

Use the same configuration options as Cursor above.

The project includes several example configurations in theexamples/directory:

- examples/github-api.json- GitHub API configuration
- examples/petstore.json- Swagger Petstore API configuration
- examples/jsonplaceholder.json- JSONPlaceholder API configuration

Note: Replace/path/to/your/mcp-rest/with the actual path to your MCP REST server directory.

If you've configured the server with auto-configuration (environment variables, CLI args, or config file), the server will be ready to use immediately:

Make a GET request to /posts/1 Show me all available endpoints Search for endpoints related to "user"

If you haven't provided auto-configuration, you can still configure the client manually:

Please configure the REST client with: - Base URL: https://api.example.com - Authentication: token - Token: your-api-token-here - Swagger URL: https://api.example.com/swagger.json

You can test your configuration before using it in Claude/Cursor:

# Test with config file node dist/index.js --config examples/jsonplaceholder.json # Test with CLI arguments node dist/index.js --base-url https://api.github.com --auth-type token --token your-token # Test with environment variables MCP_REST_BASE_URL=https://httpbin.org MCP_REST_AUTH_TYPE=token MCP_REST_TOKEN=test node dist/index.js

If you see "✅ Auto-configured REST client for [URL]", the configuration is working correctly.

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

One shared context layer for AI agents and humans — live API specs, DB schemas, and versioned contracts across repos so every agent and teammate works from the same source of truth.

The MCP server for Bitrix24 provides AI assistants with structured access to the Bitrix24 API. It delivers up-to-date method descriptions, parameters, and valid values, allowing assistants to work with precise data instead of guesswork. This reduces code errors and accelerates Bitrix24 integration development.

A TypeScript MCP server to access Apifox API data via Stdio.

Provides API documentation from Apifox projects as a data source for AI programming tools that support MCP.

A tool to retrieve API interface information from YApi, with authentication configurable via environment variables.

Clix MCP Server for assisting Clix SDK/API integrations with semantic search across Clix docs and SDK source (iOS, Android, Flutter, React Native).

Check software end-of-life (EOL) dates and support status using the endoflife.date API to provide accurate lifecycle and security information.

Fetches API information from Feishu OpenAPI for seamless integration and management within an IDE.

Unified MCP server for Ignite UI — documentation, API, and CLI scaffolding

Provides educational content, model information, and read-only API interactions for Lerian developers.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.