Provides containerization support for deploying the MCP server, with detailed instructions for building and running the server in a Docker environment.
Integrates with GitHub Actions for CI/CD pipeline automation, enabling automated testing and deployment of the MCP server.
Incorporates pytest for running the test suite, including coverage reporting for quality assurance of the MCP server code.
Built on Python, providing async/await patterns for efficient API interactions and supporting comprehensive error handling for API operations.
Integrates Ruff for code linting and formatting, ensuring code quality and consistency throughout the MCP server codebase.
Company API MCP Server Template
A template for creating Model Context Protocol (MCP) servers that integrate with your company's API using FastMCP.
Overview
This template provides a starting point for building MCP servers that can interact with your company's REST API. It includes:
- Authentication handling (Bearer token)
- Comprehensive error handling and logging
- In-memory caching for improved performance
- Rate limiting to prevent API abuse
- Full CRUD operations (Create, Read, Update, Delete)
- Health check and status monitoring
- Docker support for easy deployment
- Comprehensive test suite
- CI/CD pipeline with GitHub Actions
- Example tools for common API operations
- Environment variable configuration
- Proper async/await patterns
Setup
- Clone this repository
- Install dependencies:
- Set environment variables:
Docker Setup
Alternatively, use Docker:
Configuration
The server can be configured using environment variables:
API_BASE_URL
: Base URL of your company's APIAPI_KEY
: API key for authenticationCACHE_TTL
: Cache time-to-live in seconds (default: 300)RATE_LIMIT_REQUESTS
: Maximum requests per minute (default: 100)
Usage
Running the server
Available Tools
The template includes six example tools:
- get_user_info(user_id): Retrieve user information by ID
- search_items(query, limit): Search for items with optional limit
- create_item(title, description): Create a new item
- update_item(item_id, title, description): Update an existing item
- delete_item(item_id): Delete an item
- get_api_status(): Check API health and status
Customization
To adapt this template for your API:
- Update the
API_BASE_URL
and authentication method inserver.py
- Modify the existing tools or add new ones based on your API endpoints
- Update the response formatting to match your API's data structure
- Add any additional error handling specific to your API
Example Tools Implementation
Basic Tool Template
CRUD Operations Examples
MCP Integration
To use this server with an MCP client, add it to your MCP configuration:
Features
Caching
The server includes an in-memory cache to improve performance and reduce API calls. Cache entries expire after the configured TTL (default: 5 minutes).
Rate Limiting
Built-in rate limiting prevents API abuse by limiting the number of requests per minute (default: 100 requests/minute).
Logging
Comprehensive logging for debugging and monitoring:
- Request/response logging
- Cache hit/miss logging
- Error logging with details
- Rate limit warnings
Error Handling
Comprehensive error handling for:
- HTTP status errors
- Network timeouts
- JSON parsing errors
- API authentication failures
- Rate limit exceeded
Flexible HTTP Methods
Support for all common HTTP methods:
- GET: Retrieve data (with caching)
- POST: Create new resources
- PUT: Update existing resources
- DELETE: Remove resources
Development
Project Structure
Adding New Tools
- Define your tool function with the
@mcp.tool()
decorator - Use
make_api_request()
to call your API - Handle errors appropriately
- Format the response for the user
Testing
Run the test suite:
Code Quality
Using ruff for linting and formatting:
Or run commands directly:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
A template for building Model Context Protocol servers that connect to company REST APIs using FastMCP, providing authentication handling, error management, and example tools for common API operations.
Related MCP Servers
- AsecurityAlicenseAqualityA TypeScript-based template for building Model Context Protocol servers, featuring fast testing, automated version management, and a clean structure for MCP tool implementations.Last updated -16414TypeScriptMIT License
- -securityFlicense-qualityA server implementation of the Model Context Protocol (MCP) that provides REST API endpoints for managing and interacting with MCP resources.Last updated -Python
- -securityAlicense-qualityA REST API built with FastAPI that exposes endpoints via Model Context Protocol (MCP), allowing clients to interact with CRUD operations through MCP interfaces.Last updated -PythonMIT License
- -securityAlicense-qualityA server that implements the Model Context Protocol (MCP) with StreamableHTTP transport, enabling standardized interaction with model services through a RESTful API interface.Last updated -1081JavaScriptMIT License