Token导航 LogoToken导航TokenDH.com
Pyright MCP Server logo
开发工具stdio官方级别未说明来源级核验

Pyright MCP Server

MCP Server

pyright-mcp是一个通过MCP协议向LLM客户端(如Claude)提供Pyright的Python静态类型检查能力的服务器,支持多工作区管理、代码补全和引用查找。

工具数

6

提示词数

0

GitHub Stars

0

资源数

0
代码分析PythonClaude开发工具Claude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

islee

提供方

islee

最后核验

2026/5/17 20:19

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run python -m pyright_mcp

详细介绍

pyright-mcp

An MCP (Model Context Protocol) server that exposes Pyright's Python static type checking capabilities to LLM clients like Claude.

Status: Phase 3 Complete - Production-ready with multi-workspace support, completions, and references. See STATUS.md for details.

Features

ToolDescriptionPhaseStatus
check_typesRun type checking on file/directory1 (MVP)✓ Implemented
health_checkCheck server health and Pyright availability1 (MVP)✓ Implemented
get_hoverGet type info and docstring at position2 (LSP)✓ Implemented
go_to_definitionFind definition location for symbol2 (LSP)✓ Implemented
get_completionsGet completion suggestions at position3 (Production)✓ Implemented
find_referencesFind all references to a symbol3 (Production)✓ Implemented

Installation

From Source (Recommended for Development)

git clone https://github.com/islee/pyright-mcp-server.git
cd pyright-mcp-server
uv sync
uv run python -m pyright_mcp

From PyPI (When Published)

# Via uv (recommended)
uv add pyright-mcp

# Via pip
pip install pyright-mcp

Configuration

Add to your Claude Desktop config (claude_desktop_config.json):

{
  "mcpServers": {
    "pyright": {
      "command": "uvx",
      "args": ["pyright-mcp"]
    }
  }
}

For development:

{
  "mcpServers": {
    "pyright": {
      "command": "uv",
      "args": ["--directory", "/path/to/pyright-mcp", "run", "python", "-m", "pyright_mcp"]
    }
  }
}

Usage

Once configured, the MCP tools are available in Claude:

# Check types in a file
check_types("/path/to/file.py")

# Check entire project
check_types("/path/to/project/")

# Get type info at position (Phase 2)
get_hover("/path/to/file.py", line=10, column=5)

# Go to definition (Phase 2)
go_to_definition("/path/to/file.py", line=10, column=5)

# Get completions (Phase 3)
get_completions("/path/to/file.py", line=10, column=5, trigger_character=".")

# Find references (Phase 3)
find_references("/path/to/file.py", line=10, column=5)

# Check health with pool stats and metrics (Phase 3)
health_check()

Phase 3 Features (Production)

Multi-Workspace Support

pyright-mcp now supports efficient multi-workspace development:

  • LSP Pool Management: Maintains up to 3 concurrent LSP clients (configurable via PYRIGHT_MCP_LSP_POOL_SIZE)
  • LRU Eviction: Automatically manages memory by evicting least-recently-used workspaces
  • Per-Workspace Metrics: Tracks operation counts, latencies, and error rates for each workspace

New Tools

  • get_completions - Get code completion suggestions at a position with context awareness
  • find_references - Find all references to a symbol across the workspace

Enhanced Health Check

The health_check tool now returns detailed pool statistics and per-workspace metrics:

{
  "status": "healthy",
  "lsp_pool": {
    "active_instances": 2,
    "max_instances": 3,
    "cache_hit_rate": 0.667,
    "eviction_count": 1,
    "workspace_switches": 3,
    "workspaces": ["/path/to/workspace1", "/path/to/workspace2"]
  },
  "metrics": {
    "uptime_seconds": 123.45,
    "workspaces": [
      {
        "workspace": "/path/to/workspace1",
        "operations": {
          "hover": {"count": 5, "avg_ms": 25.3, "errors": 0},
          "definition": {"count": 3, "avg_ms": 35.2, "errors": 0},
          "completion": {"count": 2, "avg_ms": 40.1, "errors": 0},
          "references": {"count": 1, "avg_ms": 50.0, "errors": 0}
        }
      }
    ]
  }
}

Use metrics to identify slow workspaces and optimize your Pyright configuration.

Configuration

Control multi-workspace behavior:

# Increase pool size for more concurrent workspaces
export PYRIGHT_MCP_LSP_POOL_SIZE=5

# Increase idle timeout (useful for slower machines)
export PYRIGHT_MCP_LSP_TIMEOUT=600

See docs/METRICS.md for detailed metrics documentation.

Requirements

  • Python 3.10+
  • uv (recommended) or pip
  • Pyright 1.1.350+ (tested with 1.1.350-1.1.408). Run health_check to verify compatibility.
  • Node.js (for Pyright, installed automatically via pyright package)

Environment Variables

VariableDefaultDescription
PYRIGHT_MCP_ALLOWED_PATHS(none)Colon-separated allowed paths. If not set, all paths allowed.
PYRIGHT_MCP_CLI_TIMEOUT30CLI execution timeout (seconds)
PYRIGHT_MCP_LOG_MODEstderrLogging: stderr, file, or both
PYRIGHT_MCP_LOG_LEVELINFOLog level: DEBUG, INFO, WARNING, ERROR
PYRIGHT_MCP_ENABLE_HEALTH_CHECKtrueEnable health_check tool
PYRIGHT_MCP_LSP_TIMEOUT300LSP idle timeout (seconds)
PYRIGHT_MCP_LSP_COMMANDpyright-langserver --stdioLSP server command
PYRIGHT_MCP_LSP_POOL_SIZE3Maximum LSP clients in pool (Phase 3)

Development

# Install dependencies
uv sync

# Run the MCP server
uv run python -m pyright_mcp

# Run tests
uv run pytest

# Type check
uv run pyright

# Lint and format
uv run ruff check .
uv run ruff format .

Architecture

┌───────────────────────────────────────────────────────┐
│                      Claude Code                      │
└───────────────────────────┬───────────────────────────┘
                            │ MCP Protocol (stdio)
                            ▼
┌───────────────────────────────────────────────────────┐
│                      pyright-mcp                      │
│  ┌─────────────┐  ┌─────────────┐  ┌───────────────┐  │
│  │ MCP Server  │  │   Tools     │  │ Backend       │  │
│  │ (FastMCP)   │◄─┤ check_types │◄─┤ Pyright CLI   │  │
│  │             │  │ get_hover   │  │ LSP Client    │  │
│  └─────────────┘  └─────────────┘  └───────────────┘  │
└───────────────────────────────────────────────────────┘
                            │
              ┌─────────────┼─────────────┐
              ▼             ▼             ▼
       ┌──────────┐  ┌──────────┐  ┌──────────────┐
       │ Pyright  │  │ Pyright  │  │ Python Files │
       │ CLI      │  │ LSP      │  │ (workspace)  │
       └──────────┘  └──────────┘  └──────────────┘

Documentation

License

GPL-3.0 - See LICENSE for details.

目录标签

目录标签

代码分析PythonClaude开发工具静态类型检查本地部署Python开发工具LLM集成开发辅助

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

6

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP