
MCP Server for Smithery Integration
MCP Server for integrating Greptile API with Smithery Framework, featuring rate limiting and API abstraction
What is MCP Server for Smithery Integration?
The MCP Server for Smithery Integration is a FastAPI-based server that connects the Greptile API with the Smithery Framework, enabling AI agents to understand and interact with codebases effectively.
How to use MCP Server?
To use the MCP Server, set up a local environment, configure your Greptile API key in the environment variables, and run the server using Uvicorn.
Key features of MCP Server?
- Standardized MCP-compliant endpoints for seamless integration.
- Robust rate limiting to manage API requests.
- Authentication and security mechanisms to protect data.
- Error handling and data transformation for consistent responses.
Use cases of MCP Server?
- Integrating AI agents with codebases for enhanced comprehension.
- Managing API requests efficiently with rate limiting.
- Providing a secure interface for AI interactions with external APIs.
FAQ from MCP Server?
- What is the purpose of the MCP Server?
The MCP Server acts as an intermediary between Smithery's AI agents and the Greptile API, facilitating interaction and comprehension of codebases.
- How do I run the MCP Server locally?
You can run the server by setting up a virtual environment, installing the required packages, configuring your API key, and starting the server with Uvicorn.
- Is there a limit on API requests?
Yes, the server implements rate limiting to control the number of requests and ensure fair usage.
MCP Server for Smithery Integration
This project implements a FastAPI-based MCP (Model Context Protocol) server that integrates the Greptile API with the Smithery Framework, enabling AI agents to comprehend and interact with codebases.
Project Overview
The MCP Server acts as a critical intermediary between Smithery's AI agents and the Greptile API, providing:
- Standardized MCP-compliant endpoints
- Robust rate limiting
- Authentication and security mechanisms
- Error handling and data transformation
- Consistent response formatting
Rate Limiter Implementation
The rate limiter implementation is defined in app/core/rate_limit.py
and has the following components:
Core Components
-
RateLimitStorage (ABC): Abstract base class for storage backends
- Defines interface with
increment
,reset
, andget_count
methods - Allows for different storage implementations
- Defines interface with
-
InMemoryRateLimitStorage: Default implementation
- Stores counters in memory using Python dictionaries
- Tracks both counts and window expiry times
- Not suitable for distributed environments
-
RateLimiter: Main service class
- Configurable via environment variables
- Provides
check_rate_limit
andreset_rate_limit
methods - Returns detailed limit information
-
FastAPI Integration:
- Middleware implementation (
RateLimitMiddleware
) - Dependency function (
rate_limiter()
) - Standard rate limit headers
- Middleware implementation (
Configuration Options
# Settings for rate limiting
RATE_LIMIT_ENABLED: bool = True
RATE_LIMIT_REQUESTS: int = 60
RATE_LIMIT_PERIOD_SECONDS: int = 60
Limitations & Future Enhancements
-
Scalability: Current implementation uses in-memory storage, which doesn't scale across multiple instances. Future implementation should use Redis or similar distributed cache.
-
External API Awareness: Should track Greptile API quotas and adapt rate limits accordingly.
-
Per-Service Limits: Implement separate rate limits for different services and endpoints.
-
Advanced Strategies: Consider implementing token bucket or sliding window algorithms for more sophisticated rate limiting.
Integration with Smithery
This MCP server follows the requirements for integration with the Smithery Framework by:
- Providing standardized endpoints that map to Greptile functionality
- Implementing proper authentication and security mechanisms
- Transforming data between Greptile API format and MCP format
- Abstracting complex logic into a standardized interface
Development
To run the server locally:
# Set up environment
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
# Configure environment variables
cp .env.example .env
# Edit .env with your Greptile API key
# Run server
uvicorn app.main:app --reload
License
MIT License