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, andignorecrates directly (not a ripgrep subprocess). Parallel file walking with per-thread searcher reuse, mmap, SIMD literal optimization, and.gitignoresupport. - GitHub: HTTP via
ureq, JSON processing viaserde_json, text compaction in Rust. - File I/O: Path validation and traversal protection in Rust.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_methods-0.2.8-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
404e196a83a511acea9f31543f977bb32828c3fbfd6f3dc9dac44231d87ccc09
|
|
| MD5 |
39a9a26c50df98ad6a79815902ab5edc
|
|
| BLAKE2b-256 |
7062947e4dc3966b3067ae8a8a0fbd1ab16bf752a7a62cacf7a2588eb7130616
|
File details
Details for the file mcp_methods-0.2.8-cp313-cp313-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp313-cp313-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.13, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
494a5ef6fac3c29faa247902026e29216f42bac8472a625c98d0b78fb75e2331
|
|
| MD5 |
8607f4e1025666ef9756fb3ad98182ff
|
|
| BLAKE2b-256 |
ffc5f0a092920fb065403339257a257f49687f15e3214f823f9bea628fb0f65a
|
File details
Details for the file mcp_methods-0.2.8-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
617ec0b694a35cfbe6852db22e7e50a944410e4555f6753155d389e26369c763
|
|
| MD5 |
c796ad35f5187ff915bd1b49c1a86c9b
|
|
| BLAKE2b-256 |
6aa595ef3c8fc8034a5a3098b250f5869bdfc712b086c5d2d61b65941de9e589
|
File details
Details for the file mcp_methods-0.2.8-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d2361c46a47b35141ee78a051b5f9f1a09365115481ddb2a0c2055226a0bbd6
|
|
| MD5 |
77cdae86b20ea78438a522f9ed268a85
|
|
| BLAKE2b-256 |
d5a2b0f55afa6631f48685fedef328d241ba86f1c394d5860863d31ae150d8d1
|
File details
Details for the file mcp_methods-0.2.8-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64a9032e94ca0601a222a648920d290e28f45c78c4460fdb3844f0564b5fbd68
|
|
| MD5 |
d673331c178be5ef2a819bdd578e433e
|
|
| BLAKE2b-256 |
c401a894f653c6fc26dac7d7d1b869170baaa1d631605def487e67927a25b580
|
File details
Details for the file mcp_methods-0.2.8-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff71803556f89346771b1f34f352f08ac2a11428d761b56e9eca27e4f10b56f2
|
|
| MD5 |
468c062e0cfb111e2b9c37dc3ec48c90
|
|
| BLAKE2b-256 |
f2f37cb1195900afe9049b3c1200c31d916639c8526fad237503485e46ad26cc
|
File details
Details for the file mcp_methods-0.2.8-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d8b8d2e048966ab6220ffb5a24ae6d70cde15e51877e381fe9163b954c1f28c
|
|
| MD5 |
4c1be61fabdc1910ee027b4fa42563a2
|
|
| BLAKE2b-256 |
191b184ee4cc947e0c1c9bf1986ad7b79890afba040ec44f86ad0e03fa47a6f8
|
File details
Details for the file mcp_methods-0.2.8-cp311-cp311-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp311-cp311-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.11, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b037b3c11e9c671d7d8483a98b0380881a631757def70e99a109aebe7e99fca
|
|
| MD5 |
cc877d0d629a0e8403635583032458ee
|
|
| BLAKE2b-256 |
d50ab5ed34c9300287e8147f1cd4dbee66fc8f8dded55aa2f3008dd9c28cdfae
|
File details
Details for the file mcp_methods-0.2.8-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1baef6a18552e5f690095d5f1998b5ffe49dc7aaa954cb103891172e6c21a818
|
|
| MD5 |
a7fe4c51beaa647f1e700cac30ee20d2
|
|
| BLAKE2b-256 |
57a636929ad4db7011be067cfa585d419e82af4eb6f16ed4aaa4d681868a5914
|
File details
Details for the file mcp_methods-0.2.8-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 2.6 MB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ad4ff63f882c5d09bf8ff268e382fd3112e4f4aa8d72e9348e03f580e734e22
|
|
| MD5 |
a8839edf49b4dbceafec9a1e7c45835a
|
|
| BLAKE2b-256 |
dc9dc0672b6f097e9fc306b93bfcefea7959004ea1d41b3c9ede27b41a042e82
|
File details
Details for the file mcp_methods-0.2.8-cp310-cp310-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp310-cp310-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.10, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c45276447cac134342245f87f900b17b9c4686c92b8b021db04ce4c3bd515448
|
|
| MD5 |
82516aa6fa7c3aca8f4dc89ff8511853
|
|
| BLAKE2b-256 |
dce054ced097d346c3c9f61e6b3b96af8427c30377da81d0d9a696993d0659ff
|
File details
Details for the file mcp_methods-0.2.8-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: mcp_methods-0.2.8-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 2.7 MB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
204de767cb683624300a069e7fd767c2d9a542aec8f45e59842063d7607a2c0f
|
|
| MD5 |
376d395fb10f1568206ce0fea0a0607d
|
|
| BLAKE2b-256 |
672104264c9ffd5ed6947d7557c21e0ca134b473f16648d25e461dd8b1f24087
|