ZM

zhjch05/mcp-plugins

分析与监控

本页由 AI 翻译,技术细节请以原文为准。 查看原文

6 stars 2 forks 质量 59 趋势 14Apache-2.0

Add plugins like observability, timeout, timing, ratelimiting, guardrails, human-in-the-loop to your MCPs

概览

This package is currently in experimental mode and may contain bugs, breaking changes, or incomplete features. Use at your own risk in development and testing environments only. A collection of MCP middleware plugins based on FastMCP to add features like observability, error handling, guardrails, allowlists, and human-in-the-loop etc. for your MCP. Can be called from python code or through a cli proxy on top of MCP. This package provides both custom middleware plugins and integrates with FastMCP's built-in middleware system. Each middleware has its own detailed documentation: : When multiple MCP servers are joined together, the tool names to be allowed or denied would be in the format " _ ". For example, if you have a server named "weather" with a tool "get_forecast", you would reference it as "weather_get_forecast" in your allowlist or denylist configuration. You may use MCP inspector to check the exact tool names.

README

以下为原文 README 节选,完整内容请查看原文。

MCP Plugins

🚧 Experimental - Not Recommended for Production Use
This package is currently in experimental mode and may contain bugs, breaking changes, or incomplete features. Use at your own risk in development and testing environments only.

A collection of MCP middleware plugins based on FastMCP to add features like observability, error handling, guardrails, allowlists, and human-in-the-loop etc. for your MCP. Can be called from python code or through a cli proxy on top of MCP.

Quick Start

pip install mcp-plugins

Usage with python (FastMCP)

from fastmcp import FastMCP

from mcp_plugins import ToolLoggingMiddleware

MCP_CONFIG = {
    "hackernews": {
      "command": "uvx",
      "args": ["mcp-hn"],
      "transport": "stdio"
    },
    "every": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-everything"],
      "transport": "stdio"
    }
}

server = FastMCP.as_proxy(MCP_CONFIG, name="MCP-HN with Tool Logging")

server.add_middleware(
    ToolLoggingMiddleware(
        log_tool_metadata=True,
        log_arguments=True,
        log_results=True,
        include_timestamps=True,
        max_log_length=1000,
    )
)

server.run(transport="streamable-http", host="0.0.0.0", port=9000)

Usage with config.json via cli proxy

mcp-plugins run config.json --transport streamable-http --host 0.0.0.0 --port 9000

config.json

{
  "mcpServers": {
    "hackernews": {
      "command": "uvx",
      "args": ["mcp-hn"],
      "transport": "stdio"
    },
    "every": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-everything"],
      "transport": "stdio"
    }
  },
  "plugins": [
    {
      "type": "tool_logging",
      "config": {
        "enabled": true,
        "log_tool_metadata": true,
        "log_arguments": true,
        "log_results": true,
        "include_timestamps": true,
        "max_log_length": 1000,
        "log_format": "human"
      }
    }
  ]
}

Available Middleware

This package provides both custom middleware plugins and integrates with FastMCP’s built-in middleware system. Each middleware has its own detailed documentation:

⚠️ Important Caveat: When multiple MCP servers are joined together, the tool names to be allowed or denied would be in the format "_". For example, if you have a server named “weather” with a tool “get_forecast”, you would reference it as “weather_get_forecast” in your allowlist or denylist configuration. You may use MCP inspector to check the exact tool names.

Custom Middleware Plugins

Logging

Human-in-the-Loop

在 GitHub 查看完整 README

安装

uvx mcp-hn
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "hackernews": { "command": "uvx", "args": ["mcp-hn"], "transport": "stdio" }, "every": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-everything"], "transport": "stdio" } }, "plugins": [ { "type": "tool_logging", "config": { "enabled": true, "log_tool_metadata": true, "log_arguments": true, "log_results": true, "include_timestamps": true, "max_log_length": 1000, "log_format": "human" } } ] }