Local MCP server for running restricted Python text filters over files
Project description
data-filter-mcp
Local MCP server that registers restricted Python filters and runs them against local json, yaml, and txt files.
What it does
register_filteraccepts Python source code with exactly one top-level function:def filter_item(data):run_filterloads a local file, passes the loaded document intofilter_item(data), and returns the text fromresult_text- Registered filters live only in memory and expire automatically based on server TTL settings
What filter code may use
Filter bodies are AST-validated against a whitelist. In addition to a curated set of builtins (len, sorted, max, min, range, enumerate, zip, sum, any, all, conversions, etc.) and safe string/dict/list methods, filters may also use:
lambdaexpressions — typically askey=arguments, e.g.sorted(data, key=lambda item: item.get("score")). Lambda bodies are validated by the same rules as the rest of the filter.json—json.loads,json.dumps.yaml—yaml.safe_load,yaml.safe_dump. The unsafeyaml.load/yaml.dumpare intentionally not exposed.re—re.match,re.search,re.fullmatch,re.findall,re.sub,re.subn,re.compile,re.escape, plusMatch/Patternmethods (group,groups,groupdict,start,end,span).
Note: re.compile runs against patterns supplied by filter code, so a pathological pattern can stall the server (ReDoS). Treat filter source as trusted-but-restricted.
Run with uvx
After publishing to PyPI, start the server with:
uvx data-filter-mcp --filter-ttl-seconds 3600 --cleanup-interval-seconds 60
Show the available CLI flags with:
uvx data-filter-mcp --help
Restricting file access with --workdir
By default the server can read any file on the local filesystem. Use one or
more --workdir flags to restrict file reads to specific directories:
uvx data-filter-mcp \
--filter-ttl-seconds 3600 \
--cleanup-interval-seconds 60 \
--workdir /Users/me/project \
--workdir /tmp/data
Rules:
- Each
--workdirvalue must be an absolute path to an existing directory. run_filterwill only accept files located inside the allowed directories.- If no
--workdirflags are provided, no restrictions are applied (backward compatible).
Example MCP client configuration:
{
"mcpServers": {
"data-filter": {
"command": "uvx",
"args": [
"data-filter-mcp",
"--filter-ttl-seconds",
"3600",
"--cleanup-interval-seconds",
"60",
"--workdir",
"/Users/me/project",
"--workdir",
"/tmp/data"
]
}
}
}
Run locally
python server.py --filter-ttl-seconds 3600 --cleanup-interval-seconds 60
python -m data_filter_mcp.server --filter-ttl-seconds 3600 --cleanup-interval-seconds 60
.venv/bin/data-filter-mcp --filter-ttl-seconds 3600 --cleanup-interval-seconds 60
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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 data_filter_mcp-0.2.1.tar.gz.
File metadata
- Download URL: data_filter_mcp-0.2.1.tar.gz
- Upload date:
- Size: 17.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f52430c1355e9882f87dfc8f2a3cbf0b9c3988fe8c42319612ade4dfe4d9425b
|
|
| MD5 |
9e7be3380614bb3fd927cc6ce59d0a01
|
|
| BLAKE2b-256 |
517bb1ba04ccbe29ec61eb4c0e00b479a7090a0537ac06363f42c8171b8e9265
|
Provenance
The following attestation bundles were made for data_filter_mcp-0.2.1.tar.gz:
Publisher:
release.yml on alxark/data-filter-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
data_filter_mcp-0.2.1.tar.gz -
Subject digest:
f52430c1355e9882f87dfc8f2a3cbf0b9c3988fe8c42319612ade4dfe4d9425b - Sigstore transparency entry: 1440220900
- Sigstore integration time:
-
Permalink:
alxark/data-filter-mcp@e560d71c2af63eb8edf58ccb9a2a8e6459ac98c9 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/alxark
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e560d71c2af63eb8edf58ccb9a2a8e6459ac98c9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file data_filter_mcp-0.2.1-py3-none-any.whl.
File metadata
- Download URL: data_filter_mcp-0.2.1-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe6254624bcfbfc5107a3301cdaa4b231c1baf7336255d27b93a9197ae495967
|
|
| MD5 |
f943b167b371bb6497eb0ba20bd30335
|
|
| BLAKE2b-256 |
ba3af19e8acecee8aee97d10c366911c8a1bdf7b2402d9b3d7eb4f0d555603f8
|
Provenance
The following attestation bundles were made for data_filter_mcp-0.2.1-py3-none-any.whl:
Publisher:
release.yml on alxark/data-filter-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
data_filter_mcp-0.2.1-py3-none-any.whl -
Subject digest:
fe6254624bcfbfc5107a3301cdaa4b231c1baf7336255d27b93a9197ae495967 - Sigstore transparency entry: 1440220909
- Sigstore integration time:
-
Permalink:
alxark/data-filter-mcp@e560d71c2af63eb8edf58ccb9a2a8e6459ac98c9 -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/alxark
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e560d71c2af63eb8edf58ccb9a2a8e6459ac98c9 -
Trigger Event:
push
-
Statement type: