@elizaos/plugin-mcp 2.0.0-alpha.7 → 2.0.11-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -0
- package/dist/cjs/index.cjs +917 -375
- package/dist/cjs/index.js.map +21 -20
- package/dist/node/actions/mcp.d.ts +6 -0
- package/dist/node/actions/mcp.d.ts.map +1 -0
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +913 -379
- package/dist/node/index.js.map +21 -20
- package/dist/node/mcp-marketplace.d.ts +69 -0
- package/dist/node/mcp-marketplace.d.ts.map +1 -0
- package/dist/node/prompts.d.ts +23 -0
- package/dist/node/prompts.d.ts.map +1 -0
- package/dist/node/provider.d.ts.map +1 -1
- package/dist/node/routes-mcp.d.ts +48 -0
- package/dist/node/routes-mcp.d.ts.map +1 -0
- package/dist/node/service.d.ts +2 -1
- package/dist/node/service.d.ts.map +1 -1
- package/dist/node/templates/errorAnalysisPrompt.d.ts.map +1 -1
- package/dist/node/templates/feedbackTemplate.d.ts +1 -6
- package/dist/node/templates/feedbackTemplate.d.ts.map +1 -1
- package/dist/node/templates/resourceAnalysisTemplate.d.ts +1 -6
- package/dist/node/templates/resourceAnalysisTemplate.d.ts.map +1 -1
- package/dist/node/templates/resourceSelectionTemplate.d.ts +1 -6
- package/dist/node/templates/resourceSelectionTemplate.d.ts.map +1 -1
- package/dist/node/templates/toolReasoningTemplate.d.ts +1 -6
- package/dist/node/templates/toolReasoningTemplate.d.ts.map +1 -1
- package/dist/node/templates/toolSelectionTemplate.d.ts +2 -7
- package/dist/node/templates/toolSelectionTemplate.d.ts.map +1 -1
- package/dist/node/tool-compatibility/integration-test.d.ts.map +1 -1
- package/dist/node/tool-compatibility/providers/openai.d.ts.map +1 -1
- package/dist/node/tool-compatibility/test-example.d.ts.map +1 -1
- package/dist/node/types.d.ts +1 -4
- package/dist/node/types.d.ts.map +1 -1
- package/dist/node/utils/error.d.ts.map +1 -1
- package/dist/node/utils/handler.d.ts.map +1 -1
- package/dist/node/utils/json.d.ts +1 -0
- package/dist/node/utils/json.d.ts.map +1 -1
- package/dist/node/utils/schemas.d.ts +0 -4
- package/dist/node/utils/schemas.d.ts.map +1 -1
- package/dist/node/utils/selection.d.ts.map +1 -1
- package/dist/node/utils/validation.d.ts.map +1 -1
- package/dist/node/utils/wrapper.d.ts.map +1 -1
- package/package.json +24 -10
- package/dist/node/actions/callToolAction.d.ts +0 -3
- package/dist/node/actions/callToolAction.d.ts.map +0 -1
- package/dist/node/actions/readResourceAction.d.ts +0 -3
- package/dist/node/actions/readResourceAction.d.ts.map +0 -1
- package/dist/node/generated/prompts/typescript/prompts.d.ts +0 -24
- package/dist/node/generated/prompts/typescript/prompts.d.ts.map +0 -1
- package/dist/tsconfig.build.tsbuildinfo +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @elizaos/plugin-mcp
|
|
2
|
+
|
|
3
|
+
elizaOS plugin that connects an Eliza agent to external [Model Context Protocol](https://modelcontextprotocol.io) (MCP) servers and exposes their tools and resources as agent capabilities.
|
|
4
|
+
|
|
5
|
+
The plugin starts `McpService`, which connects to one or more MCP servers (stdio, SSE, or streamable-HTTP), discovers their tools and resources, and surfaces them through a single `MCP` action and an `MCP` provider. It is consumed by an elizaOS agent: add it to the character `plugins` array and configure servers under `settings.mcp.servers`.
|
|
6
|
+
|
|
7
|
+
Node-only. `index.browser.ts` is a browser-unavailable entry because the MCP SDK's stdio/SSE transports require Node APIs (`eliza.platforms` is `["node"]`).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun add @elizaos/plugin-mcp # or: npm install / yarn add
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Add the plugin and declare servers in your character file:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"name": "Your Character",
|
|
22
|
+
"plugins": ["@elizaos/plugin-mcp"],
|
|
23
|
+
"settings": {
|
|
24
|
+
"mcp": {
|
|
25
|
+
"servers": {
|
|
26
|
+
"github": {
|
|
27
|
+
"type": "stdio",
|
|
28
|
+
"command": "npx",
|
|
29
|
+
"args": ["-y", "@modelcontextprotocol/server-github"],
|
|
30
|
+
"env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>" }
|
|
31
|
+
},
|
|
32
|
+
"my-http-server": {
|
|
33
|
+
"type": "streamable-http",
|
|
34
|
+
"url": "https://example.com/mcp"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"maxRetries": 2
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Config lives entirely in `settings.mcp`, not in environment variables. The host `PATH` is forwarded to stdio child processes automatically. Every server config is validated by `@elizaos/security/mcp-server-config` (`validateMcpServerConfig`) before connect/spawn; configs that fail validation are skipped and logged at error level.
|
|
44
|
+
|
|
45
|
+
## Configuration
|
|
46
|
+
|
|
47
|
+
| Key | Type | Default | Description |
|
|
48
|
+
|---|---|---|---|
|
|
49
|
+
| `mcp.servers` | `Record<string, McpServerConfig>` | — | Map of server name → transport config |
|
|
50
|
+
| `mcp.maxRetries` | `number` | `2` | Max reconnect attempts per server |
|
|
51
|
+
|
|
52
|
+
Transport config (see `src/types.ts`):
|
|
53
|
+
|
|
54
|
+
- **stdio** — `{ type: "stdio", command, args?, env?, cwd?, timeoutInMillis? }`
|
|
55
|
+
- **HTTP/SSE** — `{ type: "streamable-http" | "http" | "sse", url, timeout? }`
|
|
56
|
+
|
|
57
|
+
## Plugin surface
|
|
58
|
+
|
|
59
|
+
- **Action `MCP`** — single entry point for all MCP operations. `action=call_tool` invokes a server tool, `action=read_resource` reads a server resource (`search_actions` / `list_connections` are cloud-runtime-only). Similes include `CALL_MCP_TOOL`, `READ_MCP_RESOURCE`, `USE_TOOL`.
|
|
60
|
+
- **Provider `MCP`** — injects a summary of connected servers, their status, tools, and resources into agent context.
|
|
61
|
+
- **`handleMcpRoutes`** (exported) — HTTP handler for `/api/mcp/*` (config CRUD, marketplace search, runtime status), wired up by the host server, not by the plugin object. The `McpRouteContext` type is also exported.
|
|
62
|
+
|
|
63
|
+
## src layout
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
src/
|
|
67
|
+
index.ts Plugin object — registers McpService, MCP action, MCP provider
|
|
68
|
+
types.ts Shared types + config guards (McpSettings, McpServerConfig, …)
|
|
69
|
+
service.ts McpService — connection lifecycle, tool calls, resource reads, ping/reconnect
|
|
70
|
+
provider.ts MCP provider — connected-server summary for agent state
|
|
71
|
+
routes-mcp.ts handleMcpRoutes — /api/mcp/config, /api/mcp/status, marketplace
|
|
72
|
+
mcp-marketplace.ts Client for registry.modelcontextprotocol.io (search + details)
|
|
73
|
+
prompts.ts Handlebars-style prompt templates
|
|
74
|
+
actions/mcp.ts mcpAction handler — op routing
|
|
75
|
+
templates/ Thin re-export shims over prompts.ts
|
|
76
|
+
utils/ Selection, validation, processing, error, and JSON helpers
|
|
77
|
+
tool-compatibility/ Per-provider tool-schema fixup (Anthropic/OpenAI/Google)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Commands
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
bun run build # bun run build.ts → dist/ (ESM + CJS + .d.ts)
|
|
84
|
+
bun run dev # hot-rebuild with bun --hot
|
|
85
|
+
bun run test # vitest run
|
|
86
|
+
bun run typecheck # tsgo --noEmit
|
|
87
|
+
bun run lint # biome check --write --unsafe
|
|
88
|
+
bun run format # biome format --write
|
|
89
|
+
bun run clean # rm -rf dist .turbo
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Security
|
|
93
|
+
|
|
94
|
+
MCP servers can execute arbitrary code, so only connect to servers you trust. Spawn/connect of every configured server is gated on `validateMcpServerConfig` from `@elizaos/security/mcp-server-config`.
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
MIT.
|