Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Turn any MCP server into a Python module
| Date | Stars |
|---|---|
| 2026-07-31 | 253 |
| 2026-08-06 | 253 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
# mcp2py: Turn any MCP server into a python module
MCP (Model Context Protocol) is an emerging standard for AI tools and
resources. The standard is compatible with normal REST API servers, but
adds extra metadata to describe tools, resources, and prompts in a
machine-readable way. This provides us with a great opportunity to
create Python modules that completely and automatically map to these MCP
servers. The biggest advantage of this approach is that we can use any
MCP server as if it were a native Python library, with zero
configuration. This can be quite a big deal as creating Python software
development kits that map to REST APIs is extremely common and was quite
a manual process. Now, if the organization hosting the REST API also
provides an MCP interface, we can automatically generate a Python SDK
for it with zero effort! Don’t worry if this is not all clear to you.
You can still leverage the power of mcp2py without knowing all the
details of MCP. All you need to know is: if you want to programmatically
interact with a website, it is likely that they have an API and as time
goes on it is very likely that they have an MCP interface for that API.
If they do, you don’t have to learn a whole set of web programming
skills, you can just use mcp2py to load the MCP server and start calling
functions right away as if it were a native Python library!
Another cool thing to note is that servers don’t have to be running
remotely. You can (and have) a lot of servers running on your own
personal computer right now. This is useful to have different programs,
possibly in different programming languages, talking to each other. As
apps that you install will more and more open up a small local server on
your machine to let LLMs interact with them, you will also be able to
leverage mcp2py to interact with these local servers. That could look
like Slack opening a server that lets you query your messages. If so,
you could then use mcp2py and have a Python module (a library in
essence) that lets you query your Slack messages directly from Python.
Super powerful!
## Overview
Here is a very simple example of using mcp2py to interact with your
local filesystem. That is not very useful as you could just use the
built-in Python libraries to do that, but it serves as a very simple
example to illustrate how mcp2py works. In this snippet of code we use
load to both start the MCP server (which is a Node.js server in this
case) and connect to it. Once connected we can call the list_directory
tool as if it were a native Python function:
``` python
from mcp2py import load
fstools = load("npx -y @modelcontextprotocol/server-filesystem /home")
fstools.list_directory("/home")
```
[DIR] maxime
This is similar to using the os library in Python:
``` python
import os
os.listdir("/home")
```
['maxime']
The main difference is that instead of going directly from Python to the
system, we send commands to a local Node (JavaScript) server and that
server has some ‘security’ features. For example, we are not allowed to
search outside of /home because that is what we have set as the root.
Those features are very useful when you want to expose your file system
to an LLM.
------------------------------------------------------------------------
## Quick Start
**1. Install**
You can install mcp2py via pip:
``` bash
pip install mcp2py
```
Python has had the pesky problem of not having a standard way to manage
dependencies for a long time. To avoid dependency conflicts, it is
recommended to use virtual environments. My favorite way to do this is
with `uv` (see here:
https://docs.astral.sh/uv/getting-started/installation/). Then you can
create a new environment and install mcp2py like this:
``` bash
# Install uv (if you haven't already)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Create a new project with a virtual environment
uv init my-mcp-project
cd my-mcp-project
# Install mcp2py
uv add mcp2py
# Activate the environment and start coding
uExcerpt of 39,899 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:c07cbbd7ce5c9891, desc:mcp server