penr-oz MCP Server

penr-oz MCP Server

A FastMCP-based server that provides secure sandboxed filesystem operations, API integration tools, and curated reasoning prompts for analysis and productivity tasks.

Category
访问服务器

README

penr-oz MCP Server

Tests

A FastMCP-based server for the penr-oz project with secure sandboxed filesystem operations. This repository provides tools for reading files and listing directories within a protected sandbox environment.

Install

Create and activate a virtual environment first:

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

For development and testing:

pip install -e ".[dev]"

Run

python server.py             # stdio server
fastmcp run server.py        # if using the FastMCP CLI

Features

Core Reasoning Prompts

The server provides a curated collection of reusable MCP prompts demonstrating best practices for common reasoning and analysis tasks.

Available Prompts

summarize_text(text: str)

  • Generate concise summaries of documents and articles
  • Extracts key points and main ideas from text content
  • Useful for: Documentation review, article analysis, content condensation

extract_tasks(text: str)

  • Identify actionable tasks and TODOs from text
  • Parses meeting notes, documentation, and messages for work items
  • Formats tasks with deadlines and assignees when mentioned
  • Useful for: Meeting notes processing, project planning, task tracking

analyze_code(code: str, language: str = "python")

  • Comprehensive code quality and structure analysis
  • Identifies potential bugs, code smells, and security vulnerabilities
  • Provides performance considerations and improvement suggestions
  • Useful for: Code reviews, technical debt assessment, learning best practices

write_design_doc(feature_description: str, context: str = "")

  • Creates detailed technical design documents
  • Covers architecture, implementation approach, and trade-offs
  • Includes sections for security, testing, and risk analysis
  • Useful for: Feature planning, system design, architectural decisions

refactor_instructions(code: str, issues: str, language: str = "python")

  • Generates step-by-step refactoring guidance
  • Explains rationale for each improvement
  • Provides refactored code with risk considerations
  • Useful for: Technical debt resolution, code modernization, pattern improvements

Backward Compatibility

summarize_prompt(text: str) - Deprecated

  • Legacy alias for summarize_text()
  • Maintained for backward compatibility with existing MCP clients
  • Use summarize_text() for new integrations

API Integration Tools

The server provides tools for integrating with external HTTP APIs, demonstrating asynchronous operations with comprehensive error handling.

Tools

fetch_json(url: str, timeout: float = 10.0)

  • Fetches JSON data from public HTTP APIs
  • Supports asynchronous operations with configurable timeout
  • Validates URLs and handles errors gracefully
  • Example: fetch_json("https://api.github.com/repos/python/cpython")

Error Handling:

  • InvalidURLError: Malformed URLs or unsupported schemes
  • TimeoutError: Request exceeds timeout duration (default: 10s)
  • HTTPError: Server returns error status (4xx, 5xx)
  • JSONDecodeError: Response is not valid JSON
  • APIError: Other network or request errors

Usage Examples:

# Fetch repository information
await fetch_json("https://api.github.com/repos/python/cpython")

# With custom timeout
await fetch_json("https://api.example.com/data", timeout=5.0)

Out of Scope:

  • Authentication and secrets management
  • Webhooks or streaming
  • Non-JSON responses

Sandboxed Filesystem Access

The server provides secure, read-only access to files within a configured sandbox directory (./sandbox/). All file paths are validated to prevent directory traversal attacks.

Tools

list_files(path: str = "")

  • Lists files and directories within the sandbox
  • Returns metadata including name, type, path, and size
  • Example: list_files("docs") to list the docs subdirectory

read_text_file(path: str)

  • Reads UTF-8 text content from files within the sandbox
  • Raises errors for non-existent files, directories, or invalid paths
  • Example: read_text_file("welcome.txt")

Resources

ozfs://{path}

  • Read-only file access via the ozfs:// protocol
  • Example: ozfs://docs/guide.md returns the file contents

Security

  • All paths are restricted to the ./sandbox/ directory
  • Directory traversal attempts (e.g., ../) are blocked
  • Paths are validated and resolved before access
  • Only UTF-8 text files can be read

Structured Validation (Pydantic)

All tools and resources use Pydantic models for input validation. Invalid inputs return structured error messages before any business logic runs.

Input Schemas

ListFilesInput

{"path": "docs"}
  • path (string, default: "") — Relative path within sandbox

ReadTextFileInput

{"path": "welcome.txt"}
  • path (string, required, min length: 1) — Relative path to file within sandbox

FetchJsonInput

{"url": "https://api.github.com/repos/python/cpython", "timeout": 10.0}
  • url (string, required, min length: 1) — HTTP(S) URL to fetch
  • timeout (float, default: 10.0, range: (0, 300]) — Request timeout in seconds

OzfsResourceInput

{"path": "docs/guide.md"}
  • path (string, required, min length: 1) — File path within sandbox

Output Schemas

FileEntry

{"name": "welcome.txt", "type": "file", "path": "welcome.txt", "size": 128}
  • name (string) — File or directory name
  • type (string) — "file" or "directory"
  • path (string) — Relative path within sandbox
  • size (int or null) — File size in bytes (null for directories)

Error Format

Invalid inputs return structured errors:

Validation error: 1 issue(s) found
  - path: String should have at least 1 character

Project layout

penr-oz-mcp-server/
|-- pyproject.toml
|-- README.md
|-- server.py
|-- app/
|   |-- __init__.py
|   |-- api.py             # API integration tools (fetch_json)
|   |-- config.py          # Server configuration and sandbox settings
|   |-- errors.py          # Centralized validation error handling
|   |-- filesystem.py      # Filesystem operations with security validation
|   |-- models.py          # Pydantic models for input/output validation
|   |-- tools.py           # MCP tools (ping, list_files, read_text_file)
|   |-- resources.py       # MCP resources (info, ozfs://)
|   `-- prompts.py         # MCP prompt templates
|-- sandbox/               # Sandboxed filesystem directory
|   |-- README.md
|   |-- welcome.txt
|   |-- docs/
|   `-- data/
`-- tests/
    |-- test_server_smoke.py
    |-- test_filesystem.py # Filesystem security and functionality tests
    |-- test_api.py        # API integration tests
    |-- test_prompts.py    # Prompt template tests
    `-- test_models.py     # Pydantic model and validation tests

Modules

  • app/api.py - API integration tools for external HTTP services (fetch_json)
  • app/config.py - Server metadata, environment flags, and sandbox configuration
  • app/errors.py - Centralized validation error formatting and extraction
  • app/filesystem.py - Secure filesystem operations with path validation
  • app/models.py - Pydantic models for tool/resource input and output validation
  • app/tools.py - MCP tools (ping, list_files, read_text_file)
  • app/resources.py - MCP resources (info, ozfs://)
  • app/prompts.py - MCP prompt templates
  • server.py - Server initialization and component registration

Adding tools, resources, and prompts

Define a new tool/resource/prompt in the relevant module, then register it in server.py.

Example registration:

from app.tools import ping
mcp.add_tool(ping)

Testing

Run the test suite locally:

pytest

Continuous Integration

This project uses GitHub Actions to automatically run tests on every push and pull request. The CI workflow tests the codebase against Python 3.10, 3.11, and 3.12 to ensure compatibility across versions.

Tests must pass before pull requests can be merged. You can view the test results in the Actions tab or by clicking the badge at the top of this README.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选