@aigne/afs-mcp 1.11.0-beta.10
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.md +26 -0
- package/README.md +297 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.cjs +11 -0
- package/dist/_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.mjs +10 -0
- package/dist/index.cjs +1895 -0
- package/dist/index.d.cts +498 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +498 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1894 -0
- package/dist/index.mjs.map +1 -0
- package/dist/kinds.cjs +181 -0
- package/dist/kinds.mjs +182 -0
- package/dist/kinds.mjs.map +1 -0
- package/package.json +58 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Proprietary License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2025 ArcBlock, Inc. All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are proprietary
|
|
6
|
+
and confidential. Unauthorized copying, modification, distribution, or use of
|
|
7
|
+
this Software, via any medium, is strictly prohibited.
|
|
8
|
+
|
|
9
|
+
The Software is provided for internal use only within ArcBlock, Inc. and its
|
|
10
|
+
authorized affiliates.
|
|
11
|
+
|
|
12
|
+
## No License Granted
|
|
13
|
+
|
|
14
|
+
No license, express or implied, is granted to any party for any purpose.
|
|
15
|
+
All rights are reserved by ArcBlock, Inc.
|
|
16
|
+
|
|
17
|
+
## Public Artifact Distribution
|
|
18
|
+
|
|
19
|
+
Portions of this Software may be released publicly under separate open-source
|
|
20
|
+
licenses (such as MIT License) through designated public repositories. Such
|
|
21
|
+
public releases are governed by their respective licenses and do not affect
|
|
22
|
+
the proprietary nature of this repository.
|
|
23
|
+
|
|
24
|
+
## Contact
|
|
25
|
+
|
|
26
|
+
For licensing inquiries, contact: legal@arcblock.io
|
package/README.md
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# @aigne/afs-mcp
|
|
2
|
+
|
|
3
|
+
AFS (Agentic File System) provider for MCP (Model Context Protocol) servers. This module allows you to mount any MCP server as a virtual filesystem, making its tools, prompts, and resources accessible through AFS's unified path-based API.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Tools as Executables**: MCP tools are exposed at `/tools/<name>` and can be executed via `afs.exec()`
|
|
8
|
+
- **Prompts as Readable Entries**: MCP prompts are available at `/prompts/<name>` with their arguments and content
|
|
9
|
+
- **Resources as Directories**: MCP resources are expanded into real AFS directory structures
|
|
10
|
+
- **Multiple Transport Support**: Connect via stdio (npx/uvx), HTTP, or SSE
|
|
11
|
+
- **Auto-generated WORLD.md**: A `/WORLD.md` file is automatically generated describing all server capabilities
|
|
12
|
+
- **Full Metadata**: Original MCP data is preserved in `entry.metadata.mcp`
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @aigne/afs-mcp
|
|
18
|
+
# or
|
|
19
|
+
pnpm add @aigne/afs-mcp
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { AFS } from "@aigne/afs";
|
|
26
|
+
import { AFSMCP } from "@aigne/afs-mcp";
|
|
27
|
+
|
|
28
|
+
// Create an MCP provider
|
|
29
|
+
const mcp = new AFSMCP({
|
|
30
|
+
name: "filesystem",
|
|
31
|
+
transport: "stdio",
|
|
32
|
+
command: "npx",
|
|
33
|
+
args: ["-y", "@anthropic-ai/mcp-server-filesystem"],
|
|
34
|
+
env: {
|
|
35
|
+
ALLOWED_PATHS: "/home/user/projects",
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
// Mount to AFS
|
|
40
|
+
const afs = new AFS();
|
|
41
|
+
afs.mount(mcp);
|
|
42
|
+
|
|
43
|
+
// Now you can use AFS to interact with the MCP server
|
|
44
|
+
// List available tools
|
|
45
|
+
const tools = await afs.list("/modules/filesystem/tools");
|
|
46
|
+
console.log(tools.data);
|
|
47
|
+
|
|
48
|
+
// Execute a tool
|
|
49
|
+
const result = await afs.exec("/modules/filesystem/tools/read_file", {
|
|
50
|
+
path: "/home/user/projects/README.md",
|
|
51
|
+
});
|
|
52
|
+
console.log(result.data);
|
|
53
|
+
|
|
54
|
+
// Read the auto-generated documentation
|
|
55
|
+
const worldMd = await afs.read("/modules/filesystem/WORLD.md");
|
|
56
|
+
console.log(worldMd.data?.content);
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Configuration
|
|
60
|
+
|
|
61
|
+
### AFSMCPOptions
|
|
62
|
+
|
|
63
|
+
| Option | Type | Required | Description |
|
|
64
|
+
|--------|------|----------|-------------|
|
|
65
|
+
| `name` | string | No | Module name (used as mount path). Default: "mcp" |
|
|
66
|
+
| `description` | string | No | Human-readable description |
|
|
67
|
+
| `transport` | "stdio" \| "http" \| "sse" | Yes | Transport type |
|
|
68
|
+
| `command` | string | stdio only | Command to execute (e.g., "npx", "uvx") |
|
|
69
|
+
| `args` | string[] | No | Command arguments |
|
|
70
|
+
| `env` | Record<string, string> | No | Environment variables |
|
|
71
|
+
| `url` | string | http/sse only | Server URL |
|
|
72
|
+
| `headers` | Record<string, string> | No | HTTP headers for authentication |
|
|
73
|
+
| `timeout` | number | No | Connection timeout in milliseconds |
|
|
74
|
+
| `maxReconnects` | number | No | Maximum reconnection attempts |
|
|
75
|
+
|
|
76
|
+
### Transport Examples
|
|
77
|
+
|
|
78
|
+
#### Stdio (npx)
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
const mcp = new AFSMCP({
|
|
82
|
+
name: "github",
|
|
83
|
+
transport: "stdio",
|
|
84
|
+
command: "npx",
|
|
85
|
+
args: ["-y", "@modelcontextprotocol/server-github"],
|
|
86
|
+
env: {
|
|
87
|
+
GITHUB_TOKEN: process.env.GITHUB_TOKEN,
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
#### Stdio (uvx)
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
const mcp = new AFSMCP({
|
|
96
|
+
name: "sqlite",
|
|
97
|
+
transport: "stdio",
|
|
98
|
+
command: "uvx",
|
|
99
|
+
args: ["mcp-server-sqlite", "--db-path", "./database.db"],
|
|
100
|
+
});
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### HTTP
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
const mcp = new AFSMCP({
|
|
107
|
+
name: "remote",
|
|
108
|
+
transport: "http",
|
|
109
|
+
url: "https://mcp.example.com/api",
|
|
110
|
+
headers: {
|
|
111
|
+
Authorization: "Bearer your-token",
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
#### SSE
|
|
117
|
+
|
|
118
|
+
```typescript
|
|
119
|
+
const mcp = new AFSMCP({
|
|
120
|
+
name: "realtime",
|
|
121
|
+
transport: "sse",
|
|
122
|
+
url: "https://mcp.example.com/sse",
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Directory Structure
|
|
127
|
+
|
|
128
|
+
When mounted, an MCP server exposes the following structure:
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
/modules/{name}/
|
|
132
|
+
WORLD.md # Auto-generated documentation
|
|
133
|
+
tools/
|
|
134
|
+
{tool-name} # Each tool as an entry
|
|
135
|
+
prompts/
|
|
136
|
+
{prompt-name} # Each prompt as an entry
|
|
137
|
+
{resource-path}/ # Resources expanded as directories
|
|
138
|
+
{resource-id} # Individual resources
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## API
|
|
142
|
+
|
|
143
|
+
### Tools
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
// List all tools
|
|
147
|
+
const tools = await afs.list("/modules/{name}/tools");
|
|
148
|
+
|
|
149
|
+
// Read tool schema
|
|
150
|
+
const tool = await afs.read("/modules/{name}/tools/{tool-name}");
|
|
151
|
+
console.log(tool.data?.metadata?.execute?.inputSchema);
|
|
152
|
+
|
|
153
|
+
// Execute a tool
|
|
154
|
+
const result = await afs.exec("/modules/{name}/tools/{tool-name}", {
|
|
155
|
+
param1: "value1",
|
|
156
|
+
param2: "value2",
|
|
157
|
+
});
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Prompts
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
// List all prompts
|
|
164
|
+
const prompts = await afs.list("/modules/{name}/prompts");
|
|
165
|
+
|
|
166
|
+
// Read prompt metadata
|
|
167
|
+
const prompt = await afs.read("/modules/{name}/prompts/{prompt-name}");
|
|
168
|
+
console.log(prompt.data?.metadata?.arguments);
|
|
169
|
+
|
|
170
|
+
// Get prompt content with arguments
|
|
171
|
+
const content = await mcp.readPrompt("/prompts/{prompt-name}", {
|
|
172
|
+
arg1: "value1",
|
|
173
|
+
});
|
|
174
|
+
console.log(content.data?.content); // Array of messages
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Resources
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
// Resources are mapped to AFS paths based on their URI
|
|
181
|
+
// e.g., "sqlite://posts" -> "/posts"
|
|
182
|
+
// e.g., "github://repos/owner/repo" -> "/repos/owner/repo"
|
|
183
|
+
|
|
184
|
+
// List resources
|
|
185
|
+
const resources = await afs.list("/modules/{name}/{resource-path}");
|
|
186
|
+
|
|
187
|
+
// Read a resource
|
|
188
|
+
const resource = await afs.read("/modules/{name}/{resource-path}/{id}");
|
|
189
|
+
console.log(resource.data?.content);
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### WORLD.md
|
|
193
|
+
|
|
194
|
+
The auto-generated `WORLD.md` provides a comprehensive overview of the MCP server:
|
|
195
|
+
|
|
196
|
+
```typescript
|
|
197
|
+
const world = await afs.read("/modules/{name}/WORLD.md");
|
|
198
|
+
console.log(world.data?.content);
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
This includes:
|
|
202
|
+
- Server information (name, transport, command/URL)
|
|
203
|
+
- Capabilities summary (tool/prompt/resource counts)
|
|
204
|
+
- Detailed tool documentation with input schemas
|
|
205
|
+
- Prompt documentation with arguments
|
|
206
|
+
- Resource listings with URIs
|
|
207
|
+
|
|
208
|
+
## Metadata Structure
|
|
209
|
+
|
|
210
|
+
All entries include MCP-specific metadata at `entry.metadata.mcp`:
|
|
211
|
+
|
|
212
|
+
### Tool Metadata
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
{
|
|
216
|
+
metadata: {
|
|
217
|
+
execute: {
|
|
218
|
+
name: "tool-name",
|
|
219
|
+
description: "...",
|
|
220
|
+
inputSchema: { /* JSON Schema */ }
|
|
221
|
+
},
|
|
222
|
+
mcp: {
|
|
223
|
+
name: "tool-name",
|
|
224
|
+
description: "...",
|
|
225
|
+
inputSchema: { /* JSON Schema */ }
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Prompt Metadata
|
|
232
|
+
|
|
233
|
+
```typescript
|
|
234
|
+
{
|
|
235
|
+
metadata: {
|
|
236
|
+
arguments: [
|
|
237
|
+
{ name: "arg1", description: "...", required: true }
|
|
238
|
+
],
|
|
239
|
+
mcp: {
|
|
240
|
+
name: "prompt-name",
|
|
241
|
+
description: "...",
|
|
242
|
+
arguments: [...]
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### Resource Metadata
|
|
249
|
+
|
|
250
|
+
```typescript
|
|
251
|
+
{
|
|
252
|
+
metadata: {
|
|
253
|
+
mcp: {
|
|
254
|
+
uri: "sqlite://posts/123",
|
|
255
|
+
name: "Post 123",
|
|
256
|
+
description: "...",
|
|
257
|
+
mimeType: "application/json"
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
## Static Methods
|
|
264
|
+
|
|
265
|
+
### AFSMCP.parseResourceUri(uri)
|
|
266
|
+
|
|
267
|
+
Parse a resource URI into its components:
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
const parsed = AFSMCP.parseResourceUri("sqlite://posts/123");
|
|
271
|
+
// { scheme: "sqlite", path: "/posts/123" }
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### AFSMCP.parseUriTemplate(template)
|
|
275
|
+
|
|
276
|
+
Extract variable names from a URI template:
|
|
277
|
+
|
|
278
|
+
```typescript
|
|
279
|
+
const vars = AFSMCP.parseUriTemplate("github://repos/{owner}/{repo}");
|
|
280
|
+
// ["owner", "repo"]
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### AFSMCP.matchPathToTemplate(path, template)
|
|
284
|
+
|
|
285
|
+
Match a path against a URI template and extract parameters:
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
const params = AFSMCP.matchPathToTemplate(
|
|
289
|
+
"/repos/arcblock/afs",
|
|
290
|
+
"github://repos/{owner}/{repo}"
|
|
291
|
+
);
|
|
292
|
+
// { owner: "arcblock", repo: "afs" }
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## License
|
|
296
|
+
|
|
297
|
+
UNLICENSED - See LICENSE file for details.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
|
|
2
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/decorate.js
|
|
3
|
+
function __decorate(decorators, target, key, desc) {
|
|
4
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
6
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
7
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
exports.__decorate = __decorate;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region \0@oxc-project+runtime@0.108.0/helpers/decorate.js
|
|
2
|
+
function __decorate(decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
export { __decorate };
|