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_files, read_file, git_issue, ElementCache

# File search — returns formatted string ready for LLM consumption
results = ripgrep_files(
    ["/path/to/project"],
    r"def \w+",
    type_filter="py",
    max_results=50,
)

# Safe file reading with allowed directory enforcement
content = read_file("src/main.py", ["/path/to/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.8-cp313-cp313-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.13Windows x86-64

mcp_methods-0.2.8-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.8-cp313-cp313-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

mcp_methods-0.2.8-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.8-cp312-cp312-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

mcp_methods-0.2.8-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.8-cp311-cp311-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

mcp_methods-0.2.8-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.8-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.8-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 404e196a83a511acea9f31543f977bb32828c3fbfd6f3dc9dac44231d87ccc09
MD5 39a9a26c50df98ad6a79815902ab5edc
BLAKE2b-256 7062947e4dc3966b3067ae8a8a0fbd1ab16bf752a7a62cacf7a2588eb7130616

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 494a5ef6fac3c29faa247902026e29216f42bac8472a625c98d0b78fb75e2331
MD5 8607f4e1025666ef9756fb3ad98182ff
BLAKE2b-256 ffc5f0a092920fb065403339257a257f49687f15e3214f823f9bea628fb0f65a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 617ec0b694a35cfbe6852db22e7e50a944410e4555f6753155d389e26369c763
MD5 c796ad35f5187ff915bd1b49c1a86c9b
BLAKE2b-256 6aa595ef3c8fc8034a5a3098b250f5869bdfc712b086c5d2d61b65941de9e589

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6d2361c46a47b35141ee78a051b5f9f1a09365115481ddb2a0c2055226a0bbd6
MD5 77cdae86b20ea78438a522f9ed268a85
BLAKE2b-256 d5a2b0f55afa6631f48685fedef328d241ba86f1c394d5860863d31ae150d8d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 64a9032e94ca0601a222a648920d290e28f45c78c4460fdb3844f0564b5fbd68
MD5 d673331c178be5ef2a819bdd578e433e
BLAKE2b-256 c401a894f653c6fc26dac7d7d1b869170baaa1d631605def487e67927a25b580

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ff71803556f89346771b1f34f352f08ac2a11428d761b56e9eca27e4f10b56f2
MD5 468c062e0cfb111e2b9c37dc3ec48c90
BLAKE2b-256 f2f37cb1195900afe9049b3c1200c31d916639c8526fad237503485e46ad26cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2d8b8d2e048966ab6220ffb5a24ae6d70cde15e51877e381fe9163b954c1f28c
MD5 4c1be61fabdc1910ee027b4fa42563a2
BLAKE2b-256 191b184ee4cc947e0c1c9bf1986ad7b79890afba040ec44f86ad0e03fa47a6f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 0b037b3c11e9c671d7d8483a98b0380881a631757def70e99a109aebe7e99fca
MD5 cc877d0d629a0e8403635583032458ee
BLAKE2b-256 d50ab5ed34c9300287e8147f1cd4dbee66fc8f8dded55aa2f3008dd9c28cdfae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1baef6a18552e5f690095d5f1998b5ffe49dc7aaa954cb103891172e6c21a818
MD5 a7fe4c51beaa647f1e700cac30ee20d2
BLAKE2b-256 57a636929ad4db7011be067cfa585d419e82af4eb6f16ed4aaa4d681868a5914

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7ad4ff63f882c5d09bf8ff268e382fd3112e4f4aa8d72e9348e03f580e734e22
MD5 a8839edf49b4dbceafec9a1e7c45835a
BLAKE2b-256 dc9dc0672b6f097e9fc306b93bfcefea7959004ea1d41b3c9ede27b41a042e82

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 c45276447cac134342245f87f900b17b9c4686c92b8b021db04ce4c3bd515448
MD5 82516aa6fa7c3aca8f4dc89ff8511853
BLAKE2b-256 dce054ced097d346c3c9f61e6b3b96af8427c30377da81d0d9a696993d0659ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 204de767cb683624300a069e7fd767c2d9a542aec8f45e59842063d7607a2c0f
MD5 376d395fb10f1568206ce0fea0a0607d
BLAKE2b-256 672104264c9ffd5ed6947d7557c21e0ca134b473f16648d25e461dd8b1f24087

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