@elizaos/plugin-mcp 1.3.5 → 2.0.0-alpha.1
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/LICENSE +23 -0
- package/dist/cjs/index.cjs +861 -1101
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js.map +25 -27
- package/dist/index.d.ts +2 -7
- package/dist/node/actions/callToolAction.d.ts +3 -0
- package/dist/node/actions/callToolAction.d.ts.map +1 -0
- package/dist/node/actions/readResourceAction.d.ts +3 -0
- package/dist/node/actions/readResourceAction.d.ts.map +1 -0
- package/dist/node/generated/prompts/typescript/prompts.d.ts +24 -0
- package/dist/node/generated/prompts/typescript/prompts.d.ts.map +1 -0
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/{index.js → node/index.js} +878 -1106
- package/dist/node/index.js.map +31 -0
- package/dist/node/provider.d.ts.map +1 -0
- package/dist/{service.d.ts → node/service.d.ts} +6 -8
- package/dist/node/service.d.ts.map +1 -0
- package/dist/node/templates/errorAnalysisPrompt.d.ts +2 -0
- package/dist/node/templates/errorAnalysisPrompt.d.ts.map +1 -0
- package/dist/node/templates/feedbackTemplate.d.ts +8 -0
- package/dist/node/templates/feedbackTemplate.d.ts.map +1 -0
- package/dist/node/templates/resourceAnalysisTemplate.d.ts +8 -0
- package/dist/node/templates/resourceAnalysisTemplate.d.ts.map +1 -0
- package/dist/node/templates/resourceSelectionTemplate.d.ts +8 -0
- package/dist/node/templates/resourceSelectionTemplate.d.ts.map +1 -0
- package/dist/node/templates/toolReasoningTemplate.d.ts +8 -0
- package/dist/node/templates/toolReasoningTemplate.d.ts.map +1 -0
- package/dist/node/templates/toolSelectionTemplate.d.ts +8 -0
- package/dist/node/templates/toolSelectionTemplate.d.ts.map +1 -0
- package/dist/{tool-compatibility/index.d.ts → node/tool-compatibility/base.d.ts} +15 -16
- package/dist/node/tool-compatibility/base.d.ts.map +1 -0
- package/dist/node/tool-compatibility/index.d.ts +7 -0
- package/dist/node/tool-compatibility/index.d.ts.map +1 -0
- package/dist/node/tool-compatibility/integration-test.d.ts +10 -0
- package/dist/node/tool-compatibility/integration-test.d.ts.map +1 -0
- package/dist/node/tool-compatibility/providers/anthropic.d.ts +11 -0
- package/dist/node/tool-compatibility/providers/anthropic.d.ts.map +1 -0
- package/dist/node/tool-compatibility/providers/google.d.ts +11 -0
- package/dist/node/tool-compatibility/providers/google.d.ts.map +1 -0
- package/dist/node/tool-compatibility/providers/openai.d.ts +18 -0
- package/dist/node/tool-compatibility/providers/openai.d.ts.map +1 -0
- package/dist/node/tool-compatibility/test-example.d.ts +4 -0
- package/dist/node/tool-compatibility/test-example.d.ts.map +1 -0
- package/dist/node/types.d.ts +191 -0
- package/dist/node/types.d.ts.map +1 -0
- package/dist/{utils → node/utils}/error.d.ts +4 -4
- package/dist/node/utils/error.d.ts.map +1 -0
- package/dist/node/utils/handler.d.ts +8 -0
- package/dist/node/utils/handler.d.ts.map +1 -0
- package/dist/node/utils/json.d.ts +11 -0
- package/dist/node/utils/json.d.ts.map +1 -0
- package/dist/node/utils/mcp.d.ts +5 -0
- package/dist/node/utils/mcp.d.ts.map +1 -0
- package/dist/node/utils/processing.d.ts +43 -0
- package/dist/node/utils/processing.d.ts.map +1 -0
- package/dist/node/utils/schemas.d.ts +72 -0
- package/dist/node/utils/schemas.d.ts.map +1 -0
- package/dist/node/utils/selection.d.ts +14 -0
- package/dist/node/utils/selection.d.ts.map +1 -0
- package/dist/node/utils/validation.d.ts +17 -0
- package/dist/node/utils/validation.d.ts.map +1 -0
- package/dist/node/utils/wrapper.d.ts +18 -0
- package/dist/node/utils/wrapper.d.ts.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +35 -44
- package/README.md +0 -275
- package/dist/actions/callToolAction.d.ts +0 -3
- package/dist/actions/callToolAction.d.ts.map +0 -1
- package/dist/actions/readResourceAction.d.ts +0 -3
- package/dist/actions/readResourceAction.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -33
- package/dist/provider.d.ts.map +0 -1
- package/dist/service.d.ts.map +0 -1
- package/dist/templates/errorAnalysisPrompt.d.ts +0 -2
- package/dist/templates/errorAnalysisPrompt.d.ts.map +0 -1
- package/dist/templates/feedbackTemplate.d.ts +0 -2
- package/dist/templates/feedbackTemplate.d.ts.map +0 -1
- package/dist/templates/resourceAnalysisTemplate.d.ts +0 -2
- package/dist/templates/resourceAnalysisTemplate.d.ts.map +0 -1
- package/dist/templates/resourceSelectionTemplate.d.ts +0 -2
- package/dist/templates/resourceSelectionTemplate.d.ts.map +0 -1
- package/dist/templates/toolReasoningTemplate.d.ts +0 -2
- package/dist/templates/toolReasoningTemplate.d.ts.map +0 -1
- package/dist/templates/toolSelectionTemplate.d.ts +0 -3
- package/dist/templates/toolSelectionTemplate.d.ts.map +0 -1
- package/dist/tool-compatibility/index.d.ts.map +0 -1
- package/dist/tool-compatibility/providers/anthropic.d.ts +0 -12
- package/dist/tool-compatibility/providers/anthropic.d.ts.map +0 -1
- package/dist/tool-compatibility/providers/google.d.ts +0 -12
- package/dist/tool-compatibility/providers/google.d.ts.map +0 -1
- package/dist/tool-compatibility/providers/openai.d.ts +0 -20
- package/dist/tool-compatibility/providers/openai.d.ts.map +0 -1
- package/dist/types.d.ts +0 -166
- package/dist/types.d.ts.map +0 -1
- package/dist/utils/error.d.ts.map +0 -1
- package/dist/utils/handler.d.ts +0 -3
- package/dist/utils/handler.d.ts.map +0 -1
- package/dist/utils/json.d.ts +0 -9
- package/dist/utils/json.d.ts.map +0 -1
- package/dist/utils/mcp.d.ts +0 -5
- package/dist/utils/mcp.d.ts.map +0 -1
- package/dist/utils/processing.d.ts +0 -43
- package/dist/utils/processing.d.ts.map +0 -1
- package/dist/utils/schemas.d.ts +0 -69
- package/dist/utils/schemas.d.ts.map +0 -1
- package/dist/utils/selection.d.ts +0 -38
- package/dist/utils/selection.d.ts.map +0 -1
- package/dist/utils/validation.d.ts +0 -34
- package/dist/utils/validation.d.ts.map +0 -1
- package/dist/utils/wrapper.d.ts +0 -27
- package/dist/utils/wrapper.d.ts.map +0 -1
- /package/dist/{provider.d.ts → node/provider.d.ts} +0 -0
package/README.md
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
# MCP Plugin for ElizaOS
|
|
2
|
-
|
|
3
|
-
[](https://conventionalcommits.org)
|
|
4
|
-
|
|
5
|
-
This plugin integrates the Model Context Protocol (MCP) with ElizaOS, allowing agents to connect to multiple MCP servers and use their resources, prompts, and tools.
|
|
6
|
-
|
|
7
|
-
## 🔍 What is MCP?
|
|
8
|
-
|
|
9
|
-
The [Model Context Protocol](https://modelcontextprotocol.io) (MCP) is an open protocol that enables seamless integration between LLM applications and external data sources and tools. It provides a standardized way to connect LLMs with the context they need.
|
|
10
|
-
|
|
11
|
-
This plugin allows your ElizaOS agents to access multiple MCP servers simultaneously, each providing different capabilities:
|
|
12
|
-
|
|
13
|
-
- **Resources**: Context and data for the agent to reference
|
|
14
|
-
- **Tools**: Functions for the agent to execute
|
|
15
|
-
|
|
16
|
-
## 📦 Installation
|
|
17
|
-
|
|
18
|
-
Install the plugin in your ElizaOS project:
|
|
19
|
-
|
|
20
|
-
- **npm**
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install @elizaos/plugin-mcp
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
- **pnpm**
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
pnpm install @elizaos/plugin-mcp
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
- **yarn**
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
yarn add @elizaos/plugin-mcp
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
- **bun**
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
bun add @elizaos/plugin-mcp
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## 🚀 Usage
|
|
45
|
-
|
|
46
|
-
1. Add the plugin to your character configuration:
|
|
47
|
-
|
|
48
|
-
```json
|
|
49
|
-
{
|
|
50
|
-
"name": "Your Character",
|
|
51
|
-
"plugins": ["@elizaos/plugin-mcp"],
|
|
52
|
-
"settings": {
|
|
53
|
-
"mcp": {
|
|
54
|
-
"servers": {
|
|
55
|
-
"github": {
|
|
56
|
-
"type": "stdio",
|
|
57
|
-
"command": "npx",
|
|
58
|
-
"args": ["-y", "@modelcontextprotocol/server-github"]
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## ⚙️ Configuration Options
|
|
67
|
-
|
|
68
|
-
MCP supports multiple transport types for connecting to servers. Each type has its own configuration options.
|
|
69
|
-
|
|
70
|
-
### Transport Types
|
|
71
|
-
|
|
72
|
-
- **`streamable-http`** or **`http`** - Modern Streamable HTTP transport (recommended)
|
|
73
|
-
- **`sse`** - Legacy Server-Sent Events transport (deprecated, use `streamable-http` instead)
|
|
74
|
-
- **`stdio`** - Process-based transport using standard input/output
|
|
75
|
-
|
|
76
|
-
### HTTP Transport Options (streamable-http, http, sse)
|
|
77
|
-
|
|
78
|
-
| Option | Type | Description |
|
|
79
|
-
| --------- | ------ | -------------------------------------- |
|
|
80
|
-
| `type` | string | Transport type: "streamable-http", "http", or "sse" |
|
|
81
|
-
| `url` | string | The URL of the HTTP/SSE endpoint |
|
|
82
|
-
| `timeout` | number | _Optional_ Timeout for connections |
|
|
83
|
-
|
|
84
|
-
### stdio Transport Options
|
|
85
|
-
|
|
86
|
-
| Option | Type | Description |
|
|
87
|
-
| ---------------- | -------- | ------------------------------------------------- |
|
|
88
|
-
| `type` | string | Must be "stdio" |
|
|
89
|
-
| `command` | string | _Optional_ The command to run the MCP server |
|
|
90
|
-
| `args` | string[] | _Optional_ Command-line arguments for the server |
|
|
91
|
-
| `env` | object | _Optional_ Environment variables to pass to the server |
|
|
92
|
-
| `cwd` | string | _Optional_ Working directory to run the server in |
|
|
93
|
-
| `timeoutInMillis`| number | _Optional_ Timeout in milliseconds for tool calls |
|
|
94
|
-
|
|
95
|
-
### Example Configuration
|
|
96
|
-
|
|
97
|
-
```json
|
|
98
|
-
{
|
|
99
|
-
"mcp": {
|
|
100
|
-
"servers": {
|
|
101
|
-
"my-modern-server": {
|
|
102
|
-
"type": "streamable-http",
|
|
103
|
-
"url": "https://example.com/mcp"
|
|
104
|
-
},
|
|
105
|
-
"my-local-server": {
|
|
106
|
-
"type": "http",
|
|
107
|
-
"url": "http://localhost:3000",
|
|
108
|
-
"timeout": 30
|
|
109
|
-
},
|
|
110
|
-
"my-legacy-server": {
|
|
111
|
-
"type": "sse",
|
|
112
|
-
"url": "http://localhost:8080"
|
|
113
|
-
},
|
|
114
|
-
"my-stdio-server": {
|
|
115
|
-
"type": "stdio",
|
|
116
|
-
"command": "mcp-server",
|
|
117
|
-
"args": ["--config", "config.json"],
|
|
118
|
-
"cwd": "/path/to/server",
|
|
119
|
-
"timeoutInMillis": 60000
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
"maxRetries": 3
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
## 🛠️ Using MCP Capabilities
|
|
128
|
-
|
|
129
|
-
Once configured, the plugin automatically exposes MCP servers' capabilities to your agent:
|
|
130
|
-
|
|
131
|
-
### Context Provider
|
|
132
|
-
|
|
133
|
-
The plugin includes one provider that adds MCP capabilities to the agent's context:
|
|
134
|
-
|
|
135
|
-
1. **`MCP`**: Lists available servers and their tools and resources
|
|
136
|
-
|
|
137
|
-
### Actions
|
|
138
|
-
|
|
139
|
-
The plugin provides two actions for interacting with MCP servers:
|
|
140
|
-
|
|
141
|
-
1. **`CALL_MCP_TOOL`**: Executes tools from connected MCP servers
|
|
142
|
-
2. **`READ_MCP_RESOURCE`**: Accesses resources from connected MCP servers
|
|
143
|
-
|
|
144
|
-
## 🔄 Plugin Flow
|
|
145
|
-
|
|
146
|
-
The following diagram illustrates the MCP plugin's flow for tool selection and execution:
|
|
147
|
-
|
|
148
|
-
```mermaid
|
|
149
|
-
graph TD
|
|
150
|
-
%% Starting point - User request
|
|
151
|
-
start[User Request] --> action[CALL_MCP_TOOL Action]
|
|
152
|
-
|
|
153
|
-
%% MCP Server Validation
|
|
154
|
-
action --> check{MCP Servers Available?}
|
|
155
|
-
check -->|No| fail[Return No Tools Available]
|
|
156
|
-
|
|
157
|
-
%% Tool Selection Flow
|
|
158
|
-
check -->|Yes| state[Get MCP Provider Data]
|
|
159
|
-
state --> prompt[Create Tool Selection Prompt]
|
|
160
|
-
|
|
161
|
-
%% First Model Use - Tool Selection
|
|
162
|
-
prompt --> model1[Use Language Model for Tool Selection]
|
|
163
|
-
model1 --> parse[Parse Selection]
|
|
164
|
-
parse --> retry{Valid Selection?}
|
|
165
|
-
|
|
166
|
-
%% Second Model Use - Retry Selection
|
|
167
|
-
retry -->|No| feedback[Generate Feedback]
|
|
168
|
-
feedback --> model2[Use Language Model for Retry]
|
|
169
|
-
model2 --> parse
|
|
170
|
-
|
|
171
|
-
%% Tool Selection Result
|
|
172
|
-
retry -->|Yes| toolAvailable{Tool Available?}
|
|
173
|
-
toolAvailable -->|No| fallback[Fallback Response]
|
|
174
|
-
|
|
175
|
-
%% Tool Execution Flow
|
|
176
|
-
toolAvailable -->|Yes| callTool[Call MCP Tool]
|
|
177
|
-
callTool --> processResult[Process Tool Result]
|
|
178
|
-
|
|
179
|
-
%% Memory Creation
|
|
180
|
-
processResult --> createMemory[Create Memory Record]
|
|
181
|
-
createMemory --> reasoningPrompt[Create Reasoning Prompt]
|
|
182
|
-
|
|
183
|
-
%% Third Model Use - Response Generation
|
|
184
|
-
reasoningPrompt --> model3[Use Language Model for Response]
|
|
185
|
-
model3 --> respondToUser[Send Response to User]
|
|
186
|
-
|
|
187
|
-
%% Styling
|
|
188
|
-
classDef model fill:#f9f,stroke:#333,stroke-width:2px;
|
|
189
|
-
classDef decision fill:#bbf,stroke:#333,stroke-width:2px;
|
|
190
|
-
classDef output fill:#bfb,stroke:#333,stroke-width:2px;
|
|
191
|
-
|
|
192
|
-
class model1,model2,model3 model;
|
|
193
|
-
class check,retry,toolAvailable decision;
|
|
194
|
-
class respondToUser,fallback output;
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
## 📋 Example: Setting Up Multiple MCP Servers
|
|
198
|
-
|
|
199
|
-
Here's a complete example configuration with multiple MCP servers of both types:
|
|
200
|
-
|
|
201
|
-
```json
|
|
202
|
-
{
|
|
203
|
-
"name": "Developer Assistant",
|
|
204
|
-
"plugins": ["@elizaos/plugin-mcp", "other-plugins"],
|
|
205
|
-
"settings": {
|
|
206
|
-
"mcp": {
|
|
207
|
-
"servers": {
|
|
208
|
-
"github": {
|
|
209
|
-
"type": "stdio",
|
|
210
|
-
"command": "npx",
|
|
211
|
-
"args": ["-y", "@modelcontextprotocol/server-github"],
|
|
212
|
-
"env": {
|
|
213
|
-
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
"puppeteer": {
|
|
217
|
-
"type": "stdio",
|
|
218
|
-
"command": "npx",
|
|
219
|
-
"args": ["-y", "@modelcontextprotocol/server-puppeteer"]
|
|
220
|
-
},
|
|
221
|
-
"google-maps": {
|
|
222
|
-
"type": "stdio",
|
|
223
|
-
"command": "npx",
|
|
224
|
-
"args": ["-y", "@modelcontextprotocol/server-google-maps"],
|
|
225
|
-
"env": {
|
|
226
|
-
"GOOGLE_MAPS_API_KEY": "<YOUR_API_KEY>"
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
},
|
|
230
|
-
"maxRetries": 2
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
## 🔒 Security Considerations
|
|
237
|
-
|
|
238
|
-
Please be aware that MCP servers can execute arbitrary code, so only connect to servers you trust.
|
|
239
|
-
|
|
240
|
-
## 🔍 Troubleshooting
|
|
241
|
-
|
|
242
|
-
If you encounter issues with the MCP plugin:
|
|
243
|
-
|
|
244
|
-
1. Check that your MCP servers are correctly configured and running
|
|
245
|
-
2. Ensure the commands are accessible in the ElizaOS environment
|
|
246
|
-
3. Review the logs for connection errors
|
|
247
|
-
4. Verify that the plugin is properly loaded in your character configuration
|
|
248
|
-
|
|
249
|
-
## 👥 Contributing
|
|
250
|
-
|
|
251
|
-
Thanks for considering contributing to our project!
|
|
252
|
-
|
|
253
|
-
### How to Contribute
|
|
254
|
-
|
|
255
|
-
1. Fork the repository.
|
|
256
|
-
2. Create a new branch: `git checkout -b feature-branch-name`.
|
|
257
|
-
3. Make your changes.
|
|
258
|
-
4. Commit your changes using conventional commits.
|
|
259
|
-
5. Push to your fork and submit a pull request.
|
|
260
|
-
|
|
261
|
-
### Commit Guidelines
|
|
262
|
-
|
|
263
|
-
We use [Conventional Commits](https://www.conventionalcommits.org/) for our commit messages:
|
|
264
|
-
|
|
265
|
-
- `test`: 💍 Adding missing tests
|
|
266
|
-
- `feat`: 🎸 A new feature
|
|
267
|
-
- `fix`: 🐛 A bug fix
|
|
268
|
-
- `chore`: 🤖 Build process or auxiliary tool changes
|
|
269
|
-
- `docs`: ✏️ Documentation only changes
|
|
270
|
-
- `refactor`: 💡 A code change that neither fixes a bug or adds a feature
|
|
271
|
-
- `style`: 💄 Markup, white-space, formatting, missing semi-colons...
|
|
272
|
-
|
|
273
|
-
## 📄 License
|
|
274
|
-
|
|
275
|
-
This plugin is released under the same license as ElizaOS.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"callToolAction.d.ts","sourceRoot":"","sources":["../../src/actions/callToolAction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EAOZ,MAAM,eAAe,CAAC;AAQvB,eAAO,MAAM,cAAc,EAAE,MAsK5B,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"readResourceAction.d.ts","sourceRoot":"","sources":["../../src/actions/readResourceAction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,MAAM,EASZ,MAAM,eAAe,CAAC;AAqDvB,eAAO,MAAM,kBAAkB,EAAE,MAiLhC,CAAC"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,MAAM,EAAU,MAAM,eAAe,CAAC;AAOxE,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,OAAO,EACL,8BAA8B,EAC9B,0BAA0B,EAC1B,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,SAAS,EACd,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,GACvB,MAAM,sBAAsB,CAAC;AAE9B,QAAA,MAAM,SAAS,EAAE,MAWhB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|