esankhyiki
This repository consists of Source Code for Model Context Protocol (MCP) Pilot Project being undertaken by Ministry of Statistics and Programme Implementation and source code for the same is being shared under GNU General Public License.
claude mcp add --transport stdio nso-india-esankhyiki-mcp python mospi_server.py:mcp \ --env OTEL_SERVICE_NAME="mospi-mcp-server" \ --env OTEL_TRACES_EXPORTER="otlp" \ --env OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317" \ --env OTEL_EXPORTER_OTLP_PROTOCOL="grpc"
How to use
This MCP server provides AI-ready access to MoSPI statistics via the Model Context Protocol. Built with FastMCP and Python, it serves data from multiple MoSPI datasets (such as PLFS, CPI, IIP, ASI, NAS, WPI, and ENERGY) and exposes a structured, chatter-friendly interface for large language models. The server enforces a four-step, sequential workflow through tools: 1_know_about_mospi_api to survey datasets, 2_get_indicators to list possible indicators for a chosen dataset, 3_get_metadata to fetch valid filter values (states, years, categories, and other params), and 4_get_data to retrieve the actual data using the selected filters. Use these tools in order to ensure valid filters and consistent results when querying MoSPI data. You can connect via HTTP (recommended for remote clients) or through stdio transport for local MCP clients, enabling seamless integration with AI agents like Claude or ChatGPT. The server also validates API parameters against Swagger specs, ensuring discipline and consistency in interactions.
To begin, run the server using the provided Python entrypoint mospi_server.py with the MCP runner (as described in the Quick Start). Once running, clients can call the tools in sequence to explore datasets, retrieve indicators, fetch metadata, and finally pull the data you need. For client integration, you can use the FastMCP client library to invoke tools by name and pass the required filter payloads, observing the documented parameter schemas in swagger_user_*.yaml.
How to install
Prerequisites:
- Python 3.11+ installed on your system.
- Git installed.
- Optional: Virtual environment tool (venv) available in your Python installation.
Step-by-step installation:
-
Clone the repository: git clone https://github.com/your-org/mospi-mcp-api.git cd mospi-mcp-api
-
Create and activate a virtual environment (recommended): python -m venv venv
macOS/Linux
source venv/bin/activate
Windows
venv\Scripts\activate
-
Install dependencies: pip install -r requirements.txt
-
(Optional) Configure environment variables for OpenTelemetry as needed. See .env.example for options.
-
Run the server locally (HTTP transport): python mospi_server.py
-
Alternative: use the FastMCP CLI to run the server via the entrypoint: fastmcp run mospi_server.py:mcp --transport http --port 8000
-
Access the MCP endpoint at http://localhost:8000/mcp
Additional notes
Notes and tips:
- This is a Python-based MCP server. The recommended deployment pattern is via Docker or a container orchestrator for production, but local development is straightforward with the steps above.
- OpenTelemetry is integrated for tracing. Configure OTEL_SERVICE_NAME and OTEL_EXPORTER_OTLP_ENDPOINT to collect traces in your observability backend.
- The Swagger specifications under swagger/ drive all parameter validation. Do not implement custom validation logic in client applications; rely on the server-side swagger specs.
- If you plan to deploy with Docker, ensure the container exposes port 8000 (or the port you choose) and that OTEL endpoints are reachable from the collector.
- The four-step tool workflow is strict: skipping step 3 (metadata) can lead to invalid filter values. Always follow 1 -> 2 -> 3 -> 4 in client implementations.
- For production, consider enabling production-grade Docker deployment with MTLS, proper logging, and Jaeger or OpenTelemetry backends for tracing.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP