Skip to main content

Reusable utility methods for MCP servers

Project description

mcp-methods

Shared Rust-powered utilities for MCP servers. Pip-installable library that provides fast file search, GitHub integration, and text processing — the common building blocks needed when writing MCP tool servers.

Install

pip install mcp-methods

For development (requires Rust toolchain + maturin):

pip install -e ".[dev]"

What's included

Function Purpose
ripgrep_files Ripgrep-powered file search with parallel walking, early termination, context lines, and multiple output modes
ripgrep Drop-in replacement for the Claude Code Grep tool interface
read_file Safe file reading with path traversal protection and line range support
git_issue Fetch GitHub issues/PRs with smart compaction (collapses code blocks, filters bots, truncates)
git_api GitHub REST API wrapper with token auth
ElementCache Drill-down cache for collapsed elements in GitHub discussions
ripgrep_lines Search through text lines with context window merging
ripgrep_json_fields Extract fields from JSON text
compact_discussion / compact_text / collapse_code_blocks Text compaction utilities
extract_github_refs Parse GitHub issue/PR references from text
detect_git_repo / validate_repo Git repository detection and validation

Usage in an MCP server

from mcp_methods import ripgrep, ripgrep_files, read_file, git_issue, ElementCache

PROJECT = "/path/to/project"

# ripgrep() — Claude Code Grep-compatible interface
# Returns all matches by default (head_limit=None means no cap)
results = ripgrep(r"def \w+", path=PROJECT, type="py")

# ripgrep_files() — full interface with multi-dir, max_results, transform
results = ripgrep_files(
    [PROJECT],
    r"def \w+",
    type_filter="py",
    relative_to=PROJECT,  # project-relative paths in output
    max_results=500,      # early termination at engine level
)

# Safe file reading with allowed directory enforcement
content = read_file("src/main.py", [PROJECT])

# GitHub issue with compaction for context windows
cache = ElementCache()
issue = cache.fetch_issue("owner/repo", 123)
# Drill into collapsed elements
element = cache.retrieve("owner/repo", 123, "cb_1")

Architecture

All heavy lifting is in Rust (PyO3/maturin), compiled to a native Python extension:

  • grep: Uses grep-regex, grep-searcher, and ignore crates directly (not a ripgrep subprocess). Parallel file walking with per-thread searcher reuse, mmap, SIMD literal optimization, and .gitignore support.
  • GitHub: HTTP via ureq, JSON processing via serde_json, text compaction in Rust.
  • File I/O: Path validation and traversal protection in Rust.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mcp_methods-0.2.10-cp313-cp313-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.13Windows x86-64

mcp_methods-0.2.10-cp313-cp313-manylinux_2_39_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

mcp_methods-0.2.10-cp313-cp313-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

mcp_methods-0.2.10-cp312-cp312-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.12Windows x86-64

mcp_methods-0.2.10-cp312-cp312-manylinux_2_39_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

mcp_methods-0.2.10-cp312-cp312-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

mcp_methods-0.2.10-cp311-cp311-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.11Windows x86-64

mcp_methods-0.2.10-cp311-cp311-manylinux_2_39_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

mcp_methods-0.2.10-cp311-cp311-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

mcp_methods-0.2.10-cp310-cp310-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.10Windows x86-64

mcp_methods-0.2.10-cp310-cp310-manylinux_2_39_x86_64.whl (3.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

mcp_methods-0.2.10-cp310-cp310-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file mcp_methods-0.2.10-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1979bc350d6378af800d77d2097eda4e2b7a59b8174e43eb12fc3aa635ccc988
MD5 3108ad80a9a106159f848b6031dde474
BLAKE2b-256 35dbd9fc66dbd7d2d1bee1b15916793b1b40035f6a6d3b17ea04d330d07d7317

See more details on using hashes here.

File details

Details for the file mcp_methods-0.2.10-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 2c20028d205d01832bfc75f8ac7812850d3a768c7148fb8fc4324ad343e2a873
MD5 a162a0e27167c796d83cc8305cd7db6b
BLAKE2b-256 93a0f33022eebc877f41822a1beedd88b7f75e500845a207fc27568cdf6ed107

See more details on using hashes here.

File details

Details for the file mcp_methods-0.2.10-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3110e6cb5dc43917c42aed2b11467c84a0ca9b174789df50ff5ceb5815db749f
MD5 cea80650de0004863dc016077fffb076
BLAKE2b-256 334f7cb9bdb90ee7b79fa31de58e84cc02b02350693166375a458c59fe51595e

See more details on using hashes here.

File details

Details for the file mcp_methods-0.2.10-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8a400364d9b9c3bf0d37e8c9fb6b1e0177038b2c6bebaa7f853cb1ece729c4fd
MD5 2b23607b52e6b65c04cdd31e09cf3d55
BLAKE2b-256 b62e17c21d50e1ae88776e556fc4bacaec9fbf89b067af00a4d033fbb0ee3950

See more details on using hashes here.

File details

Details for the file mcp_methods-0.2.10-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 c1cc0653b3c5af13eb3922886f9c2307302f39211d2932090ec8544d03239b5e
MD5 f31a302407a8456163463c1ae46f73b3
BLAKE2b-256 327ff7fb698fd6a6dff9b44239954e925079bfd7055933e4aa41e0e103a88534

See more details on using hashes here.

File details

Details for the file mcp_methods-0.2.10-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0d3c895e943fbc966518b7918ecd90b58056f79536b0987a49d8a8d6399447db
MD5 52f5ba14e68621fbd04ba4338fcd4792
BLAKE2b-256 be1c732cbc3930a4b135995c82f2a5abc6867c33c2878143f2e04d020ceb15aa

See more details on using hashes here.

File details

Details for the file mcp_methods-0.2.10-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d76e88acdc8c3e3505aec5bb184705a225d8f730f628b9c55594785ad8ec4df1
MD5 841e960d66adaf971381407a9037f0ac
BLAKE2b-256 416af77ceb2247da201fb00652dde48067d591e9e75c0ff8995157216d4414d5

See more details on using hashes here.

File details

Details for the file mcp_methods-0.2.10-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 90608b2952a597266fbac752f6f370fc76a82d206aa8ce926b81c26c7ea2815f
MD5 f207d546814f199d227ce5c04bb549ae
BLAKE2b-256 d31586bb2a34b4505ff4ef99df4a34262297288962bb6559a513f8fe6a0258d0

See more details on using hashes here.

File details

Details for the file mcp_methods-0.2.10-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b2fda627e9cd82d7122b4927e00ade75816da11c1178000df1121b91da1f30b8
MD5 e60b91a5507f11dfbbd540f405f66737
BLAKE2b-256 beced29f52f8729a62e578ac68a9c588b37617276d3b1e69626ed0dd8781891b

See more details on using hashes here.

File details

Details for the file mcp_methods-0.2.10-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 54b2ad10e841659e5e0b297be5888db1586425e4e64087d79a4f23ce8c46722c
MD5 acb887a55894393cea2a33663f64f92d
BLAKE2b-256 c17e9f21937be3b016e9bf8f3cb57b7fe056315cdd90441b1a658523adde3e3e

See more details on using hashes here.

File details

Details for the file mcp_methods-0.2.10-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 38439bb038a5b97c90406761394d6b94c985a850481f5780e5747e417a44c3bb
MD5 be1cc01ed50a98cf3d8c5310493e8f19
BLAKE2b-256 ef989bf16b11354af68f546930fb81ccd128244a5ff39563edce337d32d9e701

See more details on using hashes here.

File details

Details for the file mcp_methods-0.2.10-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.10-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 079395123d50a95ace0b2b79294a82bb206577a6816964d3cfcee97be25866a6
MD5 75986046c0356b5ac18b0b9f958e7708
BLAKE2b-256 d29ce90f36aea22589d75e36cb0261d6be48796d7883daec5cb36f6dd535acf5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page