What You're Building

An MCP (Multi-Capability Provider) server acts as a bridge, exposing custom tools to AI assistants such as Claude. When a user installs your MCP server package and connects it to their Claude instance, the AI can seamlessly invoke your tools as if they were part of its own conversational capabilities. This allows for powerful integrations, enabling AI to perform specific tasks based on user prompts. For example, a user could ask Claude to "Check NHIF coverage for outpatient surgery," which would then trigger your MCP server's tool to retrieve and return the relevant structured data.

pip install your-mcp-server
# Then Claude can:
# "Check NHIF coverage for outpatient surgery" → calls your tool → returns structured result

Step 1: Set Up the Project (2 min)

The initial setup involves creating a basic Python project structure. This includes a main package directory, a `pyproject.toml` file for package metadata and build configuration, a `README.md` for documentation, and a GitHub Actions workflow file for continuous integration. This scaffold forms the foundation for your MCP server.

your-mcp-server/
├── src/
│   └── your_package/
│       ├── __init__.py
│       └── main.py
├── pyproject.toml
├── README.md
└── .github/
    └── workflow/

Step 2: Define Your Tools

Inside your package, you’ll define the functions that your MCP server will expose. These functions represent the tools the AI can use. For instance, you might create a function to fetch NHIF coverage details. This function should accept parameters relevant to the query (e.g., type of service) and return a structured output, typically in JSON format, which Claude can then parse and present to the user.

The `main.py` file will contain the core logic for your tools. You'll need to import necessary libraries and define your functions. Each function should be clearly documented, indicating its purpose, parameters, and return types. This makes it easier for both you and the AI to understand how to use them.

Step 3: Configure `pyproject.toml`

The `pyproject.toml` file is crucial for packaging your Python project. It specifies metadata such as the package name, version, author, and dependencies. For an MCP server, you’ll need to include dependencies that enable tool exposure and interaction with AI assistants. This file also guides the build process, ensuring your package can be installed and distributed correctly.

Key sections in `pyproject.toml` include `[project]` for general metadata and `[project.entry-points."mcp.tools"]` which is vital for registering your tools with the MCP framework. This entry point tells the system where to find the functions that constitute your tools.

Example pyproject.toml snippet showing MCP tool entry point configuration

Step 4: Build and Publish

Once your project is structured and configured, you can build your Python package. This typically involves using a build tool like `setuptools` or `poetry`, which are often managed via `pyproject.toml`. The build process generates distribution files (e.g., wheels and source archives) that can be uploaded to a package index like PyPI (Python Package Index).

Before publishing, it’s good practice to test your package locally. You can create a virtual environment, install your package using `pip install .`, and then attempt to interact with it as an AI assistant would. This helps catch any installation or runtime errors. After successful local testing, you can upload your package to PyPI using tools like `twine`. This makes your MCP server accessible to anyone who wishes to install and use it with their AI assistants.

Step 5: Integrate with AI Assistants

After publishing, users can install your MCP server package using pip. The integration with AI assistants like Claude is usually straightforward. The AI platform typically has a mechanism to discover and load installed MCP servers. Once loaded, the AI can query the available tools and execute them based on user prompts.

The process of connecting your tool to an AI involves ensuring the AI's framework recognizes the entry points defined in your `pyproject.toml`. This allows the AI to dynamically load your Python functions as callable tools. The user experience is designed to be as seamless as possible, abstracting away the underlying complexity of tool execution.

The East Africa Coordination Infrastructure

The MCP server architecture is part of a broader coordination infrastructure in East Africa. This infrastructure aims to standardize how AI assistants can access and utilize various services and data sources across the region. By providing a common framework for tool exposure, it facilitates the development of more sophisticated AI applications tailored to local needs and contexts.

Every tool within this ecosystem begins with the same foundational scaffold. This consistency ensures interoperability and simplifies the development process for new tools. The ability to quickly build and publish these tools, as demonstrated by this guide, is crucial for the rapid expansion and evolution of the AI coordination infrastructure in East Africa. It empowers developers to contribute specialized functionalities, enhancing the overall capabilities of AI assistants operating within the region.

What's Next?

With your first MCP server published, you can now explore creating more complex tools, integrating with external APIs, and contributing to the growing ecosystem. The ability to expose custom functionalities to AI assistants opens up a vast landscape of possibilities for building intelligent applications and services.