MCP Data API
A FastMCP-based server that provides tools for API discovery and execution, hierarchical category management, and SQL query execution through the Model Context Protocol.
README
MCP Data API
A Model Context Protocol (MCP) server that provides access to data APIs, category management, and SQL query execution capabilities.
Overview
MCP Data API is a FastMCP-based server that exposes various data access tools through the Model Context Protocol. It enables AI agents and applications to interact with backend services for API discovery, execution, and database queries.
Features
- Category Management: Browse and navigate API categories in a hierarchical structure
- API Discovery: Search and retrieve API definitions by category or name
- API Execution: Execute APIs with dynamic parameters
- SQL Query Execution: Run SQL queries against configured databases
- MCP Protocol Support: Full compatibility with MCP clients and AI agents
Architecture
The service acts as a bridge between MCP clients and backend services:
MCP Client → MCP Data API Server → Backend Services
├── chatgpt-api-service
├── chatdb-visual-service
└── llm-workflow-service
Installation
Prerequisites
- Python 3.10 or higher
- pip package manager
Setup
- Clone the repository:
git clone <repository-url>
cd mcp_data_api
- Install dependencies:
pip install -e ".[dev]"
- Configure environment variables (optional):
cp .env.example .env
# Edit .env with your configuration
Configuration
The MCP server requires the following headers for authentication:
app_id: Application identifier (e.g., "984")dbName: Database name (e.g., "hc_data_center")
MCP Client Configuration
Add the following to your MCP client configuration:
{
"mcpServers": {
"api-data-server": {
"url": "http://127.0.0.1:32001/data/api/mcp",
"header": {
"app_id": "984",
"dbName": "hc_data_center"
}
}
}
}
Usage
Starting the Server
# Development mode
python -m src.main
# Production mode with uvicorn
uvicorn src.main:app --host 0.0.0.0 --port 32001
Using with MCP Clients
Python Client Example
from fastmcp import Client
from fastmcp.client.transports import SSETransport
# Configure transport with headers
transport = SSETransport(
url="http://127.0.0.1:32001/data/api/mcp",
headers={
"app_id": "984",
"dbName": "hc_data_center"
}
)
# Create client
client = Client(transport)
async with client:
# List available tools
tools = await client.list_tools()
print(f"Available tools: {[t.name for t in tools]}")
# Call a tool
result = await client.call_tool("get_categories", {})
print(result)
Available Tools
1. get_categories
Retrieves the hierarchical list of API categories.
Parameters:
- None
Returns: List of Category objects with flattened hierarchy
2. get_apis_by_category
Gets all APIs belonging to a specific category.
Parameters:
category_id(integer): The category ID
Returns: List of APIBasic objects
3. get_api_details
Retrieves detailed information for specific APIs.
Parameters:
api_names(string): Comma-separated list of API names
Returns: List of detailed API objects with parameter definitions
4. execute_api
Executes a single API with provided parameters.
Parameters:
api_name(string): Name of the API to executeparameters(object): JSON object containing API parameters
Returns: API execution result
5. execute_sql
Executes a SQL query against the configured database.
Parameters:
sql(string): SQL query to execute
Returns: Query results in standardized format
Testing
Run Unit Tests
pytest tests/unit -v
Run Integration Tests
# Ensure the MCP server is running first
pytest tests/integration -v
Manual Testing
Run the integration test script directly:
python tests/integration/test_mcp_client.py
Project Structure
mcp_data_api/
├── src/
│ ├── models/ # Data models
│ ├── services/ # Business logic services
│ ├── tools/ # MCP tool implementations
│ ├── data_access/ # Data access layer
│ ├── cache/ # Caching implementations
│ └── utils/ # Utility functions
├── tests/
│ ├── unit/ # Unit tests
│ ├── integration/ # Integration tests
│ └── mock_data/ # Test data
├── docs/
│ └── API_DOCUMENTATION.md # Detailed API documentation
├── pyproject.toml # Project configuration
└── README.md # This file
API Documentation
For detailed API documentation, see API_DOCUMENTATION.md.
Development
Code Style
The project uses:
- Black for code formatting
- Ruff for linting
- pytest for testing
Format code:
black src tests
Lint code:
ruff check src tests
Adding New Tools
- Define the tool in
src/tools/ - Implement the service logic in
src/services/ - Add tests in
tests/unit/andtests/integration/ - Update documentation
Troubleshooting
Connection Issues
If you encounter connection errors:
- Verify the MCP server is running
- Check that the URL and port are correct
- Ensure headers (app_id, dbName) are properly configured
- Verify backend services are accessible
405 Method Not Allowed
This error typically means:
- The MCP server is not running at the specified URL
- The endpoint path is incorrect
- The server doesn't support the MCP protocol at that endpoint
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
License
[Specify your license here]
Support
For issues and questions:
- Create an issue in the repository
- Contact the development team
Changelog
Version 0.1.0 (2026-02-05)
- Initial release
- MCP server implementation
- Category and API management tools
- SQL query execution
- Integration tests
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
Neon Database
MCP server for interacting with Neon Management API and databases
E2B
Using MCP to run code via e2b.
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.