@elizaos/plugin-mcp 1.0.0-beta.54
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/.github/workflows/npm-deploy.yml +122 -0
- package/.npmrc.template +2 -0
- package/README.md +234 -0
- package/biome.json +34 -0
- package/dist/index.js +1214 -0
- package/images/banner.jpg +0 -0
- package/images/logo.jpg +0 -0
- package/package.json +53 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
name: Publish Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- 1.x
|
|
7
|
+
- 0.x
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
verify_version:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
outputs:
|
|
14
|
+
should_publish: ${{ steps.check.outputs.should_publish }}
|
|
15
|
+
version: ${{ steps.check.outputs.version }}
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout repository
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
with:
|
|
20
|
+
fetch-depth: 0
|
|
21
|
+
|
|
22
|
+
- name: Check if package.json version changed
|
|
23
|
+
id: check
|
|
24
|
+
run: |
|
|
25
|
+
echo "Current branch: ${{ github.ref }}"
|
|
26
|
+
|
|
27
|
+
# Get current version
|
|
28
|
+
CURRENT_VERSION=$(jq -r .version package.json)
|
|
29
|
+
echo "Current version: $CURRENT_VERSION"
|
|
30
|
+
|
|
31
|
+
# Get previous commit hash
|
|
32
|
+
git rev-parse HEAD~1 || git rev-parse HEAD
|
|
33
|
+
PREV_COMMIT=$(git rev-parse HEAD~1 2>/dev/null || git rev-parse HEAD)
|
|
34
|
+
|
|
35
|
+
# Check if package.json changed
|
|
36
|
+
if git diff --name-only HEAD~1 HEAD | grep "package.json"; then
|
|
37
|
+
echo "Package.json was changed in this commit"
|
|
38
|
+
|
|
39
|
+
# Get previous version if possible
|
|
40
|
+
if git show "$PREV_COMMIT:package.json" 2>/dev/null; then
|
|
41
|
+
PREV_VERSION=$(git show "$PREV_COMMIT:package.json" | jq -r .version)
|
|
42
|
+
echo "Previous version: $PREV_VERSION"
|
|
43
|
+
|
|
44
|
+
if [ "$CURRENT_VERSION" != "$PREV_VERSION" ]; then
|
|
45
|
+
echo "Version changed from $PREV_VERSION to $CURRENT_VERSION"
|
|
46
|
+
echo "should_publish=true" >> $GITHUB_OUTPUT
|
|
47
|
+
else
|
|
48
|
+
echo "Version unchanged"
|
|
49
|
+
echo "should_publish=false" >> $GITHUB_OUTPUT
|
|
50
|
+
fi
|
|
51
|
+
else
|
|
52
|
+
echo "First commit with package.json, will publish"
|
|
53
|
+
echo "should_publish=true" >> $GITHUB_OUTPUT
|
|
54
|
+
fi
|
|
55
|
+
else
|
|
56
|
+
echo "Package.json not changed in this commit"
|
|
57
|
+
echo "should_publish=false" >> $GITHUB_OUTPUT
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
|
|
61
|
+
|
|
62
|
+
publish:
|
|
63
|
+
needs: verify_version
|
|
64
|
+
if: needs.verify_version.outputs.should_publish == 'true'
|
|
65
|
+
runs-on: ubuntu-latest
|
|
66
|
+
permissions:
|
|
67
|
+
contents: write
|
|
68
|
+
steps:
|
|
69
|
+
- name: Checkout repository
|
|
70
|
+
uses: actions/checkout@v4
|
|
71
|
+
with:
|
|
72
|
+
fetch-depth: 0
|
|
73
|
+
|
|
74
|
+
- name: Create Git tag
|
|
75
|
+
run: |
|
|
76
|
+
git config user.name "github-actions[bot]"
|
|
77
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
78
|
+
git tag -a "v${{ needs.verify_version.outputs.version }}" -m "Release v${{ needs.verify_version.outputs.version }}"
|
|
79
|
+
git push origin "v${{ needs.verify_version.outputs.version }}"
|
|
80
|
+
env:
|
|
81
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
82
|
+
|
|
83
|
+
- name: Setup Bun
|
|
84
|
+
uses: oven-sh/setup-bun@v2
|
|
85
|
+
|
|
86
|
+
- name: Install dependencies
|
|
87
|
+
run: bun install --frozen-lockfile
|
|
88
|
+
|
|
89
|
+
- name: Build package
|
|
90
|
+
run: bun run build
|
|
91
|
+
|
|
92
|
+
- name: Publish to npm
|
|
93
|
+
run: |
|
|
94
|
+
# strip βrefs/heads/β prefix
|
|
95
|
+
BRANCH=${GITHUB_REF#refs/heads/}
|
|
96
|
+
if [[ "$BRANCH" == "1.x" ]]; then
|
|
97
|
+
echo "Publishing to npm under the 'beta' tag"
|
|
98
|
+
bun publish --tag beta
|
|
99
|
+
else
|
|
100
|
+
echo "Publishing to npm under the 'latest' tag"
|
|
101
|
+
bun publish
|
|
102
|
+
fi
|
|
103
|
+
env:
|
|
104
|
+
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
105
|
+
|
|
106
|
+
create_release:
|
|
107
|
+
needs: [verify_version, publish]
|
|
108
|
+
if: needs.verify_version.outputs.should_publish == 'true'
|
|
109
|
+
runs-on: ubuntu-latest
|
|
110
|
+
permissions:
|
|
111
|
+
contents: write
|
|
112
|
+
steps:
|
|
113
|
+
- name: Create GitHub Release
|
|
114
|
+
uses: actions/create-release@v1
|
|
115
|
+
env:
|
|
116
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
117
|
+
with:
|
|
118
|
+
tag_name: "v${{ needs.verify_version.outputs.version }}"
|
|
119
|
+
release_name: "v${{ needs.verify_version.outputs.version }}"
|
|
120
|
+
body: "Release v${{ needs.verify_version.outputs.version }}"
|
|
121
|
+
draft: false
|
|
122
|
+
prerelease: false
|
package/.npmrc.template
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
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
|
+
- **Prompts**: Templated messages and workflows
|
|
15
|
+
- **Tools**: Functions for the agent to execute
|
|
16
|
+
|
|
17
|
+
## π¦ Installation
|
|
18
|
+
|
|
19
|
+
Install the plugin in your ElizaOS project:
|
|
20
|
+
|
|
21
|
+
- **npm**
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @elizaos/plugin-mcp
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
- **pnpm**
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pnpm install @elizaos/plugin-mcp
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
- **yarn**
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
yarn add @elizaos/plugin-mcp
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
- **bun**
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
bun add @elizaos/plugin-mcp
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## π Usage
|
|
46
|
+
|
|
47
|
+
1. Add the plugin to your character configuration:
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"name": "Your Character",
|
|
52
|
+
"plugins": ["@elizaos/plugin-mcp"],
|
|
53
|
+
"settings": {
|
|
54
|
+
"mcp": {
|
|
55
|
+
"servers": {
|
|
56
|
+
"github": {
|
|
57
|
+
"type": "stdio",
|
|
58
|
+
"name": "Code Server",
|
|
59
|
+
"command": "npx",
|
|
60
|
+
"args": ["-y", "@modelcontextprotocol/server-github"]
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## βοΈ Configuration Options
|
|
69
|
+
|
|
70
|
+
MCP supports two types of servers: "stdio" and "sse". Each type has its own configuration options.
|
|
71
|
+
|
|
72
|
+
### Common Options
|
|
73
|
+
|
|
74
|
+
| Option | Type | Description |
|
|
75
|
+
| ---------- | ------- | ----------------------------------------------- |
|
|
76
|
+
| `type` | string | The type of MCP server: "stdio" or "sse" |
|
|
77
|
+
| `name` | string | The display name of the server |
|
|
78
|
+
| `timeout` | number | Timeout in seconds for tool calls (default: 60) |
|
|
79
|
+
| `disabled` | boolean | Whether the server is disabled |
|
|
80
|
+
|
|
81
|
+
### stdio Server Options
|
|
82
|
+
|
|
83
|
+
| Option | Type | Description |
|
|
84
|
+
| --------- | -------- | ------------------------------------------------- |
|
|
85
|
+
| `command` | string | The command to run the MCP server |
|
|
86
|
+
| `args` | string[] | Command-line arguments for the server |
|
|
87
|
+
| `env` | object | Environment variables to pass to the server |
|
|
88
|
+
| `cwd` | string | _Optional_ Working directory to run the server in |
|
|
89
|
+
|
|
90
|
+
### sse Server Options
|
|
91
|
+
|
|
92
|
+
| Option | Type | Description |
|
|
93
|
+
| --------- | ------ | -------------------------------------- |
|
|
94
|
+
| `url` | string | The URL of the SSE endpoint |
|
|
95
|
+
|
|
96
|
+
## π οΈ Using MCP Capabilities
|
|
97
|
+
|
|
98
|
+
Once configured, the plugin automatically exposes MCP servers' capabilities to your agent:
|
|
99
|
+
|
|
100
|
+
### Context Providers
|
|
101
|
+
|
|
102
|
+
The plugin includes three providers that add MCP capabilities to the agent's context:
|
|
103
|
+
|
|
104
|
+
1. `MCP_SERVERS`: Lists available servers and their tools, resources and prompts
|
|
105
|
+
|
|
106
|
+
## π Plugin Flow
|
|
107
|
+
|
|
108
|
+
The following diagram illustrates the MCP plugin's flow for tool selection and execution:
|
|
109
|
+
|
|
110
|
+
```mermaid
|
|
111
|
+
graph TD
|
|
112
|
+
%% Starting point - User request
|
|
113
|
+
start[User Request] --> action[CALL_TOOL Action]
|
|
114
|
+
|
|
115
|
+
%% MCP Server Validation
|
|
116
|
+
action --> check{MCP Servers Available?}
|
|
117
|
+
check -->|No| fail[Return No Tools Available]
|
|
118
|
+
|
|
119
|
+
%% Tool Selection Flow
|
|
120
|
+
check -->|Yes| state[Get MCP Provider Data]
|
|
121
|
+
state --> prompt[Create Tool Selection Prompt]
|
|
122
|
+
|
|
123
|
+
%% First Model Use - Tool Selection
|
|
124
|
+
prompt --> model1[Use Language Model for Tool Selection]
|
|
125
|
+
model1 --> parse[Parse Selection]
|
|
126
|
+
parse --> retry{Valid Selection?}
|
|
127
|
+
|
|
128
|
+
%% Second Model Use - Retry Selection
|
|
129
|
+
retry -->|No| feedback[Generate Feedback]
|
|
130
|
+
feedback --> model2[Use Language Model for Retry]
|
|
131
|
+
model2 --> parse
|
|
132
|
+
|
|
133
|
+
%% Tool Selection Result
|
|
134
|
+
retry -->|Yes| toolAvailable{Tool Available?}
|
|
135
|
+
toolAvailable -->|No| fallback[Fallback Response]
|
|
136
|
+
|
|
137
|
+
%% Tool Execution Flow
|
|
138
|
+
toolAvailable -->|Yes| callTool[Call MCP Tool]
|
|
139
|
+
callTool --> processResult[Process Tool Result]
|
|
140
|
+
|
|
141
|
+
%% Memory Creation
|
|
142
|
+
processResult --> createMemory[Create Memory Record]
|
|
143
|
+
createMemory --> reasoningPrompt[Create Reasoning Prompt]
|
|
144
|
+
|
|
145
|
+
%% Third Model Use - Response Generation
|
|
146
|
+
reasoningPrompt --> model3[Use Language Model for Response]
|
|
147
|
+
model3 --> respondToUser[Send Response to User]
|
|
148
|
+
|
|
149
|
+
%% Styling
|
|
150
|
+
classDef model fill:#f9f,stroke:#333,stroke-width:2px;
|
|
151
|
+
classDef decision fill:#bbf,stroke:#333,stroke-width:2px;
|
|
152
|
+
classDef output fill:#bfb,stroke:#333,stroke-width:2px;
|
|
153
|
+
|
|
154
|
+
class model1,model2,model3 model;
|
|
155
|
+
class check,retry,toolAvailable decision;
|
|
156
|
+
class respondToUser,fallback output;
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
## π Example: Setting Up Multiple MCP Servers
|
|
160
|
+
|
|
161
|
+
Here's a complete example configuration with multiple MCP servers of both types:
|
|
162
|
+
|
|
163
|
+
```json
|
|
164
|
+
{
|
|
165
|
+
"name": "Developer Assistant",
|
|
166
|
+
"plugins": ["@elizaos/plugin-mcp", "other-plugins"],
|
|
167
|
+
"settings": {
|
|
168
|
+
"mcp": {
|
|
169
|
+
"servers": {
|
|
170
|
+
"github": {
|
|
171
|
+
"command": "npx",
|
|
172
|
+
"args": ["-y", "@modelcontextprotocol/server-github"],
|
|
173
|
+
"env": {
|
|
174
|
+
"GITHUB_PERSONAL_ACCESS_TOKEN": "<YOUR_TOKEN>"
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
"puppeteer": {
|
|
178
|
+
"command": "npx",
|
|
179
|
+
"args": ["-y", "@modelcontextprotocol/server-puppeteer"]
|
|
180
|
+
},
|
|
181
|
+
"google-maps": {
|
|
182
|
+
"command": "npx",
|
|
183
|
+
"args": ["-y", "@modelcontextprotocol/server-google-maps"],
|
|
184
|
+
"env": {
|
|
185
|
+
"GOOGLE_MAPS_API_KEY": "<YOUR_API_KEY>"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"maxRetries": 2
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## π Security Considerations
|
|
196
|
+
|
|
197
|
+
Please be aware that MCP servers can execute arbitrary code, so only connect to servers you trust.
|
|
198
|
+
|
|
199
|
+
## π Troubleshooting
|
|
200
|
+
|
|
201
|
+
If you encounter issues with the MCP plugin:
|
|
202
|
+
|
|
203
|
+
1. Check that your MCP servers are correctly configured and running
|
|
204
|
+
2. Ensure the commands are accessible in the ElizaOS environment
|
|
205
|
+
3. Review the logs for connection errors
|
|
206
|
+
4. Verify that the plugin is properly loaded in your character configuration
|
|
207
|
+
|
|
208
|
+
## π₯ Contributing
|
|
209
|
+
|
|
210
|
+
Thanks for considering contributing to our project!
|
|
211
|
+
|
|
212
|
+
### How to Contribute
|
|
213
|
+
|
|
214
|
+
1. Fork the repository.
|
|
215
|
+
2. Create a new branch: `git checkout -b feature-branch-name`.
|
|
216
|
+
3. Make your changes.
|
|
217
|
+
4. Commit your changes using conventional commits.
|
|
218
|
+
5. Push to your fork and submit a pull request.
|
|
219
|
+
|
|
220
|
+
### Commit Guidelines
|
|
221
|
+
|
|
222
|
+
We use [Conventional Commits](https://www.conventionalcommits.org/) for our commit messages:
|
|
223
|
+
|
|
224
|
+
- `test`: π Adding missing tests
|
|
225
|
+
- `feat`: πΈ A new feature
|
|
226
|
+
- `fix`: π A bug fix
|
|
227
|
+
- `chore`: π€ Build process or auxiliary tool changes
|
|
228
|
+
- `docs`: βοΈ Documentation only changes
|
|
229
|
+
- `refactor`: π‘ A code change that neither fixes a bug or adds a feature
|
|
230
|
+
- `style`: π Markup, white-space, formatting, missing semi-colons...
|
|
231
|
+
|
|
232
|
+
## π License
|
|
233
|
+
|
|
234
|
+
This plugin is released under the same license as ElizaOS.
|
package/biome.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
|
|
3
|
+
"organizeImports": {
|
|
4
|
+
"enabled": true
|
|
5
|
+
},
|
|
6
|
+
"linter": {
|
|
7
|
+
"enabled": true,
|
|
8
|
+
"rules": {
|
|
9
|
+
"recommended": true,
|
|
10
|
+
"correctness": {
|
|
11
|
+
"noUnusedVariables": "error"
|
|
12
|
+
},
|
|
13
|
+
"a11y": {
|
|
14
|
+
"useButtonType": "off"
|
|
15
|
+
},
|
|
16
|
+
"style": {
|
|
17
|
+
"noCommaOperator": "off"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"formatter": {
|
|
22
|
+
"enabled": true,
|
|
23
|
+
"indentWidth": 2,
|
|
24
|
+
"indentStyle": "space",
|
|
25
|
+
"lineWidth": 100
|
|
26
|
+
},
|
|
27
|
+
"javascript": {
|
|
28
|
+
"formatter": {
|
|
29
|
+
"quoteStyle": "double",
|
|
30
|
+
"trailingCommas": "es5",
|
|
31
|
+
"semicolons": "always"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|