MM

maximerivest/mcp2py

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

254 stars 23 forks Качество 63 Тренд 18MIT

maximerivest/mcp2py — это кандидат на MCP-сервер, импортированный из https://github.com/maximerivest/mcp2py.

Обзор

maximerivest/mcp2py — это кандидат на MCP-сервер, импортированный из https://github.com/maximerivest/mcp2py.

Обзор (машинный перевод)

MCP (Model Context Protocol) — это новый стандарт для инструментов искусственного интеллекта и ресурсы. Стандарт совместим с обычными серверами REST API, но добавляет дополнительные метаданные для описания инструментов, ресурсов и запросов в машиночитаемый способ. Это даёт нам отличную возможность создавать модули на Python, которые полностью и автоматически сопоставляются с этими MCP серверы. Главное преимущество такого подхода в том, что мы можем использовать любые MCP-сервер как будто это нативная библиотека на Python, но без нуля Конфигурация. Это может быть довольно серьёзной задачей при создании программного обеспечения на Python Наборы для разработки, сопоставляющиеся с REST API, чрезвычайно распространены и довольно хорошо ручной процесс. Теперь, если организация, размещающая REST API, также предоставляет интерфейс MCP, мы можем автоматически сгенерировать Python-SDK Без каких-либо усилий! Не волнуйтесь, если вам всё не ясно. Вы всё равно можете использовать силу mcp2py, не зная всех Детали MCP. Всё, что вам нужно знать: если вы хотите программно взаимодействовать с сайтом, вероятно, у них есть API и по времени Судя по всему, очень вероятно, что у них есть интерфейс MCP для этого API. Если да, вам не придётся изучать целый набор веб-программирования

Эта страница переведена автоматически. Технические детали смотрите в оригинале.

README

Показан фрагмент оригинального README. Открыть оригинал.

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:

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:

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

Открыть полный README на GitHub

Установка

This server does not publish a one-line install command.

Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →