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
grep_files Ripgrep-powered file search with parallel walking, early termination, context lines, and multiple output modes
grep 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
grep_lines Search through text lines with context window merging
grep_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 grep_files, read_file, git_issue, ElementCache

# File search — returns formatted string ready for LLM consumption
results = grep_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.7-cp313-cp313-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e7247785b5e9aaa535bb88950db2ee440e95d00eb83f944f495102bc26c399ec
MD5 944b00c559b34cb1347db9b4d509715e
BLAKE2b-256 db35d8fccc5e5487d898178847c25a8e399bc0512be6da51ebcbf8b6edc83040

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 fabff920911480566669d243cf03afb001aa0f44e98dedb8d63a7713c6d5850c
MD5 a7dc529954bd90df742b6305f084d0fe
BLAKE2b-256 00bdbdc0f4f4789ad460e150f881cf8a734994fa9eeb966280ae51a8da1cc29b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e4fce2edee363ed364f23f3782adbcbed4a8a33a91c0560379727fa83416473
MD5 e192880c960d9e3ec6290c812c7858af
BLAKE2b-256 c16902048517be5621247e7978237cfaffdc8ca4c0ddfd02e05e4e5f1f4cff76

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 755c9c3f4c76d9383cf62011b788ebc0430ffa2625a1a9a5cb5b8f428f5ee936
MD5 4ffc52312f2b3191be5bf8a5d209c385
BLAKE2b-256 30027366e17e824a2dc5f7246c572b930dad929a4aab2d5131704d71d7f3bfea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 06d9ed57e1adeb916ff9e623e81561a447e4d7b17fbd7349599652e41c0ef68c
MD5 293b34261456b477c1a76013d6bd636c
BLAKE2b-256 e1cbedb7758cf9a1e84d1644d005d72256f681888ba4539af50f6abef1133545

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ea3f9e1fba2f504551bd409221914486a1357cca51eddba5424b1db6391bc340
MD5 c9dcbbeb4875f1e6b035b98d4c526f27
BLAKE2b-256 4436621b3f3752d3b1c35cbe91a6cd6a6a10976f900c501378f60b2f35607470

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e9559bac51e313d83362190c4e94f70d87e1f1e83ba401e503199884067c39df
MD5 9b679cdc5ad1c68731f90c6631d6d28f
BLAKE2b-256 c3a10de2b00e1810d24f9d692b525f53e19e62e368952587c425d0f54cf8cf7d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 d597440a61d277a6f3f5781653e29198a317a7e4425a46b8d17f80723014e9e6
MD5 83036e96d38b3c3726ce0a036b910534
BLAKE2b-256 7467f0200c1d4d38a2549195ee053b1bcfaaca6693f91c0f61dac9ba37354fb4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec917e9797acbf33d75d956d343ce65cbce3fe1fc5c410238bb7be5092333c9c
MD5 818978dccc2dfdd6cbe1f6a5f7d9df61
BLAKE2b-256 15116f20216915a0aa81c8abe8bfe5db6fbc85972cacc56eb7868e7e70d346e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 8d42ca16a4e8a372ab90fb3ae7a98e32cffa58fb1c034a8c30d43063a103700c
MD5 2411ada8204484e6bf6856eff6b0f9e9
BLAKE2b-256 508f6ae73ce7cdcfbf3930d4a6c1f3e803daf52dad3a884f7ff1442fcdbb03df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 a7e901eb59110dc9d5be936b5287b31bb639a4ef2aaccd84b2ee6e8a3412eb2b
MD5 daf46a9ece5641065867b1303593d68c
BLAKE2b-256 396b49a74e389bdcd3c8d9392313dc70aa5076e3050d6b60c63280016232f9c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d0341c9227092e3f36dab67870cfc7bd7856152120d671473673dd9080f4c268
MD5 71a08454e75b594ba68e18dd859d5a2d
BLAKE2b-256 48bfbd4a44dff674177b01c7ce4d14db61712991692c96f3726688247aea406b

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