Python语言服务器

一个基于Pyright的MCP服务器,提供Python代码的类型检查、悬停信息、自动补全、定义跳转、引用查找、文档符号获取和代码格式化功能。

  • by daedalus
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 daedalus/mcp-pyright

使用说明

mcp版权

公开Pyright语言服务器功能的MCP服务器

mcp名称:io.github.daedalus/mcp-yright

安装

pip install mcp-pyright

用法

MCP服务器可以与任何兼容MCP的客户端一起使用。它公开了以下工具:

类型检查

from mcp_pyright import mcp

# Run type checking
result = check_types(code="x: int = 'hello'")

获取悬停信息

# Get type information at position
result = get_hover(code="x: int = 1", position=0)

获得完成

# Get code completions
result = get_completions(code="prin", position=4)

获取定义

# Find definition location
result = get_definition(code="def foo(): pass\nfoo()", position=15)

查找引用

# Find all references
result = find_references(code="x = 1\nx", position=5)

获取文档符号

# Get all symbols in document
result = get_document_symbols(code="class Foo: pass\ndef bar(): pass")

格式化代码

# Format Python code
result = format_code(code="x=1\ny=2")

发展

git clone https://github.com/daedalus/mcp-pyright.git
cd mcp-pyright
pip install -e ".[test]"

# run tests
pytest

# format
ruff format src/ tests/

# lint
ruff check src/ tests/

# type check
mypy src/

许可证

麻省理工学院