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
# By default returns all matches; set max_results to cap early
results = ripgrep_files(
    ["/path/to/project"],
    r"def \w+",
    type_filter="py",
)

# 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.9-cp313-cp313-win_amd64.whl (2.6 MB view details)

Uploaded CPython 3.13Windows x86-64

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 54e231641d9ea8d627dfff21de1b63c9b13d54324ff534c8fa38977df82fafe2
MD5 c5147ac597d6ce15faf84742fe7c44fa
BLAKE2b-256 5b3879c6ea3e0be581badd76c7c52439e62a0c16bc3ecbeeed58c6a870c1d841

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 bca3f2f55ca5f6f099fa42d410857e2b9173b7cc8591729c899cdd0ca0c4546a
MD5 826afe08a03731fb3c2917cde9f708ef
BLAKE2b-256 88344d1261b247f7ac9994316d915abe0c32b0239d7566d89c2fecf4af1ee3f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 694be407defabedbf8821de289e3914dadbfd14678c91363ca6ad3cf8aece81d
MD5 e95f7bf21d5000f510f244b5dc6f5c1a
BLAKE2b-256 19c1c589d94850a08cabaec1c3ed9cc08bb1d96072b2c9d08ac5f9b99d6dd6a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4bb5d916875e99dcd59ca21a2c37925673d5061244f22fea2fbb9cb96cde1159
MD5 dfd3df840309b7692032553818ab5b41
BLAKE2b-256 9e96c54b2ce3913b552836b33758a0702dbea2fd55ec3a5c0e8af243c6298334

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 615e14da3eb32d1bbc67367b831954be3fdcb5437527f7c6efba1805a6e67318
MD5 9f0a00802cfcf9201e4e57fe234b3bd3
BLAKE2b-256 4874d89a5bc044b5037b8a77ae1299ff800fb0b7bd8138cb8b3bca5c30cd2f9c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6c71e798974b0261b1b5d79a7224229f7f44b6e5a878d3a5aff58311b4b6bc04
MD5 c202ba28b8b7302f1b415830da7e7bc0
BLAKE2b-256 08d493232a7aa857a01c63da8b1fe60ab0367e97c384607d0700485996622700

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 597a7433feccee044750b820debe92ae1494d39bd981f0811b179572a54fbeef
MD5 f19de72bacbf3521374c5bd2b35e583f
BLAKE2b-256 ae9e471fd8e08abcf15b709d788bc04d1d82c1159f4dd95c35f226d78547ae44

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 dcacbf220671cc11e551d7c8320eb2bac3d90340c7489b725a3f1b8cbf686022
MD5 2aeec563de5ab6735a4cbed296913a39
BLAKE2b-256 f9d83fbbc37aaf4639cc5307c8c134bfe94ab90f3b7f8f1958788691b36281aa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 de290cac9995f6b4113430822e376fba3b4eb5d0ef741609415293f70441fdec
MD5 b3b8e4a55c878395fd9b58f3c69d414f
BLAKE2b-256 0eb14ad91b303c9f0c8a5d6047461aec9cabc3c804b2363e6db2201770768cf5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 57276e2b64ec48b2c24e058d7cd149cc262b1f8cc0f503ff270cc406f8cf805a
MD5 e7d7c05c5d65938dac9d2b0baac31762
BLAKE2b-256 c4e15ce17e4c5d2b6db9380adda1c2b0d30bd897c66494d5fde659c0923494b9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 18cf82f394a908ed3d0b0f94e471dbffe21de946ca0caacaec1be8aafcbd51e7
MD5 177804cda9ff14f82df4c5dfcb1f5dc4
BLAKE2b-256 9f152d9ace630a283ca1e376bf6668c26811b4326e5e194cbdafcb029c5a1757

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mcp_methods-0.2.9-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bc83e43390ef9dc8c6ddbfe46d886625083adf50d30c278f86dbd7f405b82594
MD5 9eccf53823babb040d2c835bf0a5ae01
BLAKE2b-256 7c313bea70c28676f7bee2c5953235c33890e92c0eb727edda1bf811589d036a

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