📦 加固的。 此包现在是effectorHQ/effector→packages/serve/. monorepo中的所有积极开发都在继续。此存储库仍可供参考。 安装:npm install @effectorhq/serve(发表于monorepo)
______________________________________________________________________
@effectorhq/serve
 ](https://nodejs.org)  
运行时MCP服务器,具有类型验证、功能发现和组合功能。
源代码仓库: 效应器HQ/效应器发球.CLI: effector-serve.
将任何技能目录包装为MCP服务器,该服务器在运行时根据声明的类型验证工具I/O,让代理通过类型签名发现功能,并建议多步骤技能链。
三个运行时层-- 打印的, 可组合, 可验证的 --建立在 效应器HQ 工具链。
______________________________________________________________________
安装
npm install @effectorhq/serve或者直接运行:
npx @effectorhq/serve ./my-skills快速开始
命令行界面
# Start a guarded MCP server (stdin/stdout)
effector-serve ./skills
# Strict mode — reject calls with type validation errors
effector-serve ./skills --strict
# Allow tools that require network access
effector-serve ./skills --allow-network
# Allow both network and subprocess
effector-serve ./skills --allow-network --allow-subprocess程序化
import { createGuardedServer } from '@effectorhq/serve';
const server = await createGuardedServer('./skills', {
strict: false, // warn on type errors (default)
allowNetwork: true, // permit network-requiring tools
allowSubprocess: false,
});
// Use handleRequest for testing or embedding
const response = server.handleRequest({
jsonrpc: '2.0',
id: 1,
method: 'tools/list',
});
console.log(response.result.tools);
// → [...your skills..., effector_discover, effector_compose, effector_inspect]______________________________________________________________________
它的作用
┌────────────────┐ ┌──────────────────┐ ┌────────────────┐
│ Your Skills │────▶│ effector-serve │────▶│ MCP Client │
│ (SKILL.md + │ │ │ │ (Claude, etc) │
│ effector.toml)│ │ ┌─ Type Guard │ └────────────────┘
└────────────────┘ │ ├─ Permissions │
│ ├─ Discovery │
│ ├─ Composition │
│ └─ Telemetry │
└──────────────────┘无效应器发球
您的MCP服务器返回技能说明。LLM用它想要的任何论据来调用工具。如果类型不匹配,您将在运行时发现——或者永远不会发现。
使用效应器发球
每 tools/call 根据声明进行验证 [effector.interface] 类型。违反权限的行为在执行前被发现。代理人可以查询 _“哪些技能接受CodeDiff?”_ 和 _“如何从CodeDiff获取通知?”_ 在运行时。
______________________________________________________________________
内置工具
效应器服务为您的技能添加了三个MCP工具:
effector_discover
通过类型签名查找技能。
{
"name": "effector_discover",
"arguments": {
"input_type": "CodeDiff",
"output_type": "ReviewReport"
}
}返回匹配的技能及其界面、权限和描述。
effector_compose
建议类型之间的多步骤技能链。
{
"name": "effector_compose",
"arguments": {
"from_type": "CodeDiff",
"to_type": "Notification",
"max_depth": 3
}
}使用BFS找到最短类型的兼容链。如果 code-review 输出 ReviewReport 和 notify 接受 Markdown,以及 format-report 桥接它们,你会得到:
CodeDiff → [code-review] → ReviewReport → [format-report] → Markdown → [notify] → Notificationeffector_inspect
查看技能的完整键入界面。
{
"name": "effector_inspect",
"arguments": { "tool_name": "code-review" }
}退货 interface, permissions, metadata,以及 inputSchema.
______________________________________________________________________
运行时验证
防护类型
每 tools/call 根据技能声明进行检查 [effector.interface]:
# effector.toml
[effector.interface]
input = "CodeDiff"
output = "ReviewReport"如果输入缺少必填字段 CodeDiff 类型(例如。, files),服务器返回结构化错误:
{
"error": {
"code": -32602,
"message": "Input validation failed: CodeDiff: missing required field: files",
"data": {
"code": "EFFECTOR_VALIDATION_ERROR",
"direction": "input",
"typeName": "CodeDiff",
"missingFields": ["files"]
}
}
}在 允许模式 (默认),验证警告通过遥测记录,但呼叫仍在继续。在 严格模式 (--strict),验证错误拒绝呼叫。
许可执行
技能在中声明权限 effector.toml:
[effector.permissions]
network = true
subprocess = false默认情况下,服务器会阻止需要的工具 network 或 subprocess.使用 --allow-network / --allow-subprocess 允许他们。
{
"error": {
"code": -32600,
"message": "Permission denied: Tool \"deploy\" requires network access. Use --allow-network to permit.",
"data": { "code": "EFFECTOR_PERMISSION_DENIED" }
}
}遥测
所有验证结果、工具调用和权限检查都在内存中的环形缓冲区中跟踪:
const stats = server.telemetry.getStats();
// {
// totalEvents: 142,
// validationPass: 120,
// validationFail: 8,
// callCount: 130,
// permissionDenied: 2,
// byTool: {
// "code-review": { calls: 45, validationPass: 44, validationFail: 1 },
// ...
// }
// }______________________________________________________________________
api参考
@effectorhq/serve
| 导出 | 描述 |
|---|---|
createGuardedServer(dir, options?) | 创建受保护的MCP服务器 |
startGuardedServer(dir, options?) | 在stdin/stdout上创建并启动 |
createTelemetry(options?) | 创建独立遥测实例 |
createPermissionEnforcer(config?) | 创建独立的权限执行器 |
handleDiscover(args, toolMap) | 发现工具处理程序(用于嵌入) |
handleCompose(args, toolMap) | 组合工具处理程序(用于嵌入) |
handleInspect(args, toolMap) | 检查工具搬运器(用于嵌入) |
ServeOptions
{
strict: false, // Reject on validation errors (default: warn)
allowNetwork: false, // Allow tools with network permission
allowSubprocess: false, // Allow tools with subprocess permission
telemetry: true, // Enable telemetry tracking
}______________________________________________________________________
命令行界面
effector-serve — Runtime MCP server with typed validation
Usage:
effector-serve [options]
Options:
--strict Reject tools/call on type validation errors
--allow-network Allow tools that declare network permission
--allow-subprocess Allow tools that declare subprocess permission
--no-telemetry Disable telemetry event tracking______________________________________________________________________
建筑
效应器发球包 @effectorhq/skill-mcp (现有的MCP服务器)和拦截 handleRequest:
┌────────────────────────────────────────┐
│ effector-serve │
│ │
stdin ─────────▶│ handleRequest() │
│ │ │
│ ├─ initialize → identity + caps │
│ ├─ tools/list → skills + 3 built-in │
│ └─ tools/call │
│ │ │
│ ├─ Permission check │
│ ├─ Type validation (guard) │
│ ├─ Telemetry recording │
│ │ │
│ ├─ Synthetic tool? │
│ │ ├─ effector_discover │
│ │ ├─ effector_compose │
│ │ └─ effector_inspect │
│ │ │
│ └─ Delegate to inner server │
│ (instruction passthrough) │
stdout ◀────────│ │
└────────────────────────────────────────┘依赖项
全部 @effectorhq/* 包,零外部依赖:
| 包装 | 用于 |
|---|---|
@effectorhq/core | 类型保护、类型检查器、错误类型 |
@effectorhq/skill-mcp | 内部MCP服务器(JSON-RPC 2.0) |
@effectorhq/compose | BFS组成建议 |
@effectorhq/types | 标准型号目录 |
______________________________________________________________________
零外部依赖
此软件包仅使用 @effectorhq/* 包和Node.js内置。这 @effectorhq/* 包本身没有外部依赖关系。整个依赖关系树是:
@effectorhq/serve
├── @effectorhq/core (0 deps)
├── @effectorhq/skill-mcp (→ @effectorhq/core)
├── @effectorhq/compose (→ @effectorhq/core, @effectorhq/types)
└── @effectorhq/types (0 deps)没有供应链风险。没有版本冲突。快速安装。
______________________________________________________________________
贡献
看 贡献.md 作为指导方针。
许可证
该项目目前根据 Apache许可证,版本2.0.
