MCP Data API

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.

Category
Visit Server

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

  1. Clone the repository:
git clone <repository-url>
cd mcp_data_api
  1. Install dependencies:
pip install -e ".[dev]"
  1. 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 execute
  • parameters (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

  1. Define the tool in src/tools/
  2. Implement the service logic in src/services/
  3. Add tests in tests/unit/ and tests/integration/
  4. Update documentation

Troubleshooting

Connection Issues

If you encounter connection errors:

  1. Verify the MCP server is running
  2. Check that the URL and port are correct
  3. Ensure headers (app_id, dbName) are properly configured
  4. 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

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. 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

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured