MCP Tools 056fda97

MCPAI代理

提供方 civicteam

AI代理 未标注 OAuth 授权 社区 / 第三方

Civic MCP Hooks是一个为模型上下文协议(MCP)设计的中间件层,用于监控、验证和转换AI工具交互,提供安全控制、审计日志和定制化功能。

一句话选型结论

按资料字段整理

MCP Tools 056fda97 属于AI代理类 MCP 服务器,传输方式未标注,OAuth 授权,没有现成安装命令,需按官方文档接入。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类AI代理 传输方式未标注 鉴权OAuth 授权 部署方式未标注
GitHub 星标 8 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

AI代理
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

适用场景

AI工具交互TypeScript本地部署中间件安全控制审计日志MCP协议

安装与配置

未标注 OAuth 授权
上游未给出传输方式
  1. 1
    准备运行环境

    按官方文档确认运行环境(常见为 Node.js 或 Python),装好后再执行安装命令。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
给代理接外部能力

让代理在任务中途调用搜索、数据库等真实工具。

多步任务编排

把一串操作拆成步骤,由代理按顺序执行。

自动化重复流程

把固定流程交给代理跑,减少手工操作。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 基础信息齐全,可以先按官方文档接入试跑。

先想清楚的地方

  • 没有现成安装命令,需要按官方文档自己填启动命令和参数。
  • 使用前要准备好OAuth 授权对应的凭据,并按最小权限配置。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在AI代理场景里让模型直接调用外部能力的人。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 不方便管理密钥或第三方授权的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
MCP Tools 056fda97当前 未标注 未标注 未标注 无 2026-05-17
Filesystem 560c4363 13 未标注 本地部署 无 2026-05-17
Server Everything (everything) 11 stdio · 本地进程 本地部署 有 2026-05-17
Time 7365cb6d 2 SSE · 服务端推送 远程部署 有 2026-05-18
Everything Claude Code 未标注 stdio · 本地进程 本地部署 有 2026-05-17
Openmemory 557e1585 未标注 stdio · 本地进程 本地部署 有 2026-05-17

服务器档案

AI代理
字段来自项目仓库与公开索引,中文说明由本站标注
提供方civicteam上游标注的维护方 civicteam
分类AI代理本站按上游分类展示
连接方式未标注上游未给出传输方式
鉴权方式OAuth 授权远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · 未标注本地安装时用到的包标识与运行时
部署类型未标注上游给出的部署形态
最近核验2026-05-17上游最后核验时间

详细介绍

12.4 KB
来自项目仓库与上游目录的原文,未做删改

Civic MCP Hooks

A middleware layer for the Model Context Protocol (MCP) that enables monitoring, validation, and transformation of AI tool interactions.

Understanding MCP and Why It Needs Hooks

What is MCP?

The Model Context Protocol (MCP) is a standard that allows AI assistants (like Claude) to interact with external tools and services. Think of it as a universal language that lets AI models:
- Read and write files
- Query databases
- Call APIs
- Execute code
- Access various services

When you use an AI assistant with MCP, it can perform real actions on your behalf, making it incredibly powerful for automation and productivity.

Why Add a Middleware Layer?

While MCP's power is exciting, it also raises important questions:
- Security: How do we ensure the AI only accesses what it should?
- Auditing: How do we track what actions were taken?
- Control: How do we prevent unintended or dangerous operations?
- Customization: How do we modify behavior for specific use cases?

This is where hooks come in. Just like web applications use middleware to handle authentication, logging, and request processing, MCP can benefit from a similar pattern.

How This Solution Works

Our approach introduces a "passthrough server" that sits between the AI and the actual MCP tools:```
AI Assistant ←→ Passthrough Server ←→ Target MCP Server
↓↑
[Hooks]


Here's what happens when the AI wants to use a tool:```
1. Request:  AI → Passthrough → Hook 1 → Hook 2 → ... → Target MCP Server
2. Response: AI ← Passthrough ← Hook 2 ← Hook 1 ← ... ← Target MCP Server

The passthrough server:
1. Intercepts all requests from the AI
2. Processes them through a chain of hooks
3. Forwards approved requests to the actual tool
4. Returns the response (also processed through hooks)

Each hook in the chain can:
- Inspect the request (What is the AI trying to do?)
- Modify the request (Change parameters, add context)
- Approve or Reject the request (Security and validation)
- Perform side effects (Audit logging, notifications, analytics)
- Transform the response (Format, filter, or enhance results)

Real-World Examples

Why do we need MCP-specific hooks? It's about separation of concerns and the unique challenges of LLM tool use.

The Core Problem: MCP servers are designed to do one thing well - provide tools. They shouldn't be cluttered with authentication logic, audit trails, or context-specific modifications. Additionally, OAuth (which MCP uses) lacks the granularity needed for LLM interactions - there's no way to express "allow file reads but only in the /docs folder" or "allow API calls but rate-limit based on content."

Example 1: LLM-Specific Guardrails

Your MCP file server provides simple file operations. But LLMs need different rules than human users:```
Human user: Can precisely click on files they need
LLM: Might try to read entire directory trees to "be helpful"

Guardrail Hook: Limits directory traversal depth, prevents reading
binary files, and caps file sizes - rules that only make sense for LLMs


The MCP server stays simple, while the hook adds LLM-specific safety rails.

**Example 2: Context-Dependent Tool Descriptions and Prompts**

The same tool might need different descriptions for different use cases:```
Standard fetch tool: "Retrieves web content"

In a research environment:
"Retrieves web content (academic sources preferred, checks Sci-Hub)"

In a corporate environment:
"Retrieves web content (internal wiki only, external sites blocked)"

The Custom Description Hook modifies tool descriptions based on your context - something the original MCP server can't and shouldn't handle.

Example 3: Forcing Transparency with Explain Hook

LLMs can use tools without explaining why. The Explain Hook adds a required "reason" parameter:```
Without hook:
AI: execute_sql("DROP TABLE users")

With Explain Hook:
AI: execute_sql("DROP TABLE users", reason="User requested database cleanup")


This modification happens at the middleware layer - the MCP server doesn't need to change.

**Example 4: Semantic Audit Trails**

MCP servers return raw responses. An Audit Hook can add semantic meaning:```
MCP Server returns: {status: "success", rowsAffected: 1523}

Audit Hook logs:
- Tool: database_query
- Action: "Bulk update customer emails"
- Impact: 1523 records modified
- Context: "Part of migration from old email domain"
- Risk level: High (bulk data modification)

The MCP server remains focused on database operations while the hook handles compliance logging.

Available Packages

This monorepo contains everything you need to add a middleware layer to MCP:

Core Infrastructure

@civic/passthrough-mcp-server
The main proxy server that intercepts MCP traffic and routes it through your hooks. This is the foundation that makes everything else possible.

@civic/hook-common
Shared utilities and TypeScript types for building hooks. Provides the AbstractHook base class that makes creating new hooks straightforward.

Example Hooks

@civic/audit-hook
Logs every request and response for debugging and compliance. Perfect for understanding what your AI is doing and maintaining an audit trail.

@civic/guardrail-hook
Implements security rules to filter and validate requests. Includes an example that prevents access to certain domains, but can be extended for any validation logic.

@civic/simple-log-hook
The simplest possible hook - just logs to console. Great starting point for understanding how hooks work and building your own.

@civic/explain-hook
Adds a "reason" parameter to all tools, encouraging the AI to explain why it's using each tool. Helpful for transparency and debugging.

@civic/playwright-tokensaver-proxy
Single stdio MCP proxy for Playwright that adds a run_code_cheap wrapper and compresses large browser_run_code outputs into compact success/failure results.

@civic/custom-description-hook
Replaces tool descriptions based on configuration. Useful for providing context-specific information about what tools do in your environment.

@civic/rate-limit-hook
Enforces rate limits on tool calls per user. Configurable limits per minute and per hour with clear retry-after responses.

@civic/local-tools-hook
A programmatic hook that allows adding local tools directly to passthrough MCP servers without requiring a separate MCP server. Perfect for defining custom tools in your application code.

Testing Tools

@civic/fetch-docs
A simple MCP server that fetches web pages and converts them to markdown. Included as a testing target for the passthrough server and hooks.

@civic/whoami-server
An MCP server that integrates with Civic Auth to identify authenticated users. Provides a "whoami" tool that returns information about the current user, useful for testing authentication flows.

Getting Started

Prerequisites

  • Node.js 18+
  • pnpm (recommended) or npm

Quick Start

  1. Clone and install:```bash
    git clone https://github.com/civicteam/mcp-hooks.git
    cd mcp-hooks
    pnpm install
    pnpm build

2. **Try the simple example:**```bash
# Terminal 1: Start the fetch-docs MCP server
cd packages/fetch-docs
pnpm start

# Terminal 2: Start the audit hook
cd packages/audit-hook
pnpm start

# Terminal 3: Start the passthrough server
cd packages/passthrough-mcp-server
export TARGET_SERVER_URL="http://localhost:33005"
export HOOKS="http://localhost:33004"
pnpm start

Now any MCP client connecting to port 34000 will have all requests logged by the audit hook before being forwarded to the fetch-docs server.

Testing with Included Examples

The test/ directory contains ready-to-run configurations:```bash
cd test
./test.sh simple-log-passthrough.json # See basic logging in action
./test.sh audit-passthrough.json # Test audit trail functionality
./test.sh guardrail-passthrough.json # Test security filtering
./test.sh playwright-tokensaver-proxy.json # Test token-efficient Playwright wrapper


## Creating Your Own Hook

Building a custom hook is straightforward:

1. **Create a new package:**```bash
mkdir packages/my-hook
cd packages/my-hook
pnpm init
  1. Install dependencies:```bash
    pnpm add @civic/hook-common @trpc/server

3. **Implement your hook:**```typescript
import { AbstractHook, createHookRouter, ToolCallRequestHookResult } from "@civic/hook-common";
import { createHTTPServer } from "@trpc/server/adapters/standalone";
import type { CallToolRequest } from "@modelcontextprotocol/sdk/types.js";

class MyHook extends AbstractHook {
  get name(): string {
    return "my-hook";
  }

  async processCallToolRequest(request: CallToolRequest): Promise<ToolCallRequestHookResult> {
    // Your logic here
    console.log(`Processing: ${toolCall.params.name}`);

    // Continue with the request
    return {
      resultType: "continue",
      request: toolCall
    };
  }
}

// Start the server
const hook = new MyHook();
const router = createHookRouter(hook);
const server = createHTTPServer({ router, createContext: () => ({}) });
server.listen(33007);
  1. Use your hook:```bash
    export HOOKS="http://localhost:33007"
    pnpm start

## Advanced Configuration

### Multiple Hooks

Hooks can be chained together:```bash
export HOOKS="http://localhost:33004,http://localhost:33005,http://localhost:33006"

They execute in order for requests and reverse order for responses.

Hook Response Types

Hooks can return three types of responses:

  • continue: Proceed with the (possibly modified) request
  • abort: Stop processing and return an error
  • respond: Return a response without calling the target server

Environment Variables

  • PORT: HTTP port for the passthrough server (default: 34000)
  • TARGET_SERVER_URL: The MCP server to forward requests to
  • TARGET_SERVER_TRANSPORT: Transport type (httpStream, sse, stdio)
  • HOOKS: Comma-separated list of hook URLs

Architecture Details

Technology Stack

  • TypeScript: Full type safety across all packages
  • tRPC: Type-safe communication between hooks and server
  • fastMCP: High-performance MCP server implementation
  • Turborepo: Monorepo build orchestration
  • Biome: Fast, modern linting and formatting
  • Vitest: Unit testing framework

Project Structure```

mcp-hooks/
├── packages/
│ ├── passthrough-mcp-server/ # Main proxy server
│ ├── hook-common/ # Shared types and utilities
│ ├── audit-hook/ # Example: Logging hook
│ ├── guardrail-hook/ # Example: Security hook
│ ├── simple-log-hook/ # Example: Minimal hook
│ ├── explain-hook/ # Example: Transparency hook
│ ├── playwright-tokensaver-proxy/ # Example: Token-efficient Playwright wrapper
│ ├── custom-description-hook/ # Example: Transform hook
│ ├── rate-limit-hook/ # Example: Rate limiting hook
│ ├── local-tools-hook/ # Example: Programmatic tools hook
│ ├── fetch-docs/ # Test MCP server
│ └── whoami-server/ # Test auth server
├── test/ # Test configurations
└── docs/ # Additional documentation


### Hook Interface

All hooks implement this simple interface:```typescript
interface Hook {
  name: string;
  processCallToolRequest?(request: CallToolRequest): Promise<ToolCallRequestHookResult>;
  processCallToolResult?(response: CallToolResult, originalCallToolRequest: CallToolRequest): Promise<ToolCallResponseHookResult>;
  processToolsList?(request: ListToolsRequest): Promise<ListToolsRequestHookResult>;
  processListToolsResult?(response: ListToolsResult, originalRequest: ListToolsRequest): Promise<ListToolsResponseHookResult>;
  processToolCallTransportError?(error: unknown, originalCallToolRequest: CallToolRequest): Promise<ToolCallTransportErrorHookResult>;
  processToolsListTransportError?(error: unknown, originalRequest: ListToolsRequest): Promise<ListToolsTransportErrorHookResult>;
}

Contributing

We welcome contributions! Please see our Contributing Guide for details.

Development Commands```bash

pnpm install # Install dependencies
pnpm build # Build all packages
pnpm test # Run tests
pnpm lint # Check code style
pnpm dev # Start in watch mode
```

License

MIT - See LICENSE for details.

常见问题

5 问
答案由本站依据条目字段整理,不引用上游原文
MCP Tools 056fda97 怎么安装?

资料没有给出安装命令,请到官方仓库或文档按说明接入;这类条目多数是生态应用,或尚未发布可安装包。

MCP Tools 056fda97 怎么在客户端里配置?

它的传输方式未标注,在客户端 MCP 配置里按官方文档填写启动命令和参数,保存后重启客户端生效。

MCP Tools 056fda97 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

MCP Tools 056fda97 需要 API Key 吗?

资料标注需要OAuth 授权认证,使用前准备好对应凭据,并按最小权限配置。

MCP Tools 056fda97 能提供哪些能力?

资料显示能力标签包括 安全控制、TypeScript、审计日志、中间件。具体工具清单以官方文档为准。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 2026-05-17。