@pi-unipi/mcp 0.1.14 → 2.0.0
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 +40 -53
- package/package.json +1 -1
- package/src/index.ts +7 -8
- package/src/tui/add-overlay.ts +11 -9
- package/src/tui/settings-overlay.ts +5 -4
package/README.md
CHANGED
|
@@ -1,32 +1,45 @@
|
|
|
1
1
|
# @pi-unipi/mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Browse a catalog of 7,800+ MCP servers, add them interactively, and use their tools in Pi. MCP (Model Context Protocol) servers expose external capabilities — GitHub operations, database queries, file system access — as tools the agent can call.
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
- **Browse Catalog**: Search and discover MCP servers from the awesome-mcp-servers collection
|
|
8
|
-
- **Interactive Add**: Split-pane overlay with server browser + JSON config editor
|
|
9
|
-
- **Settings Management**: Enable/disable, edit, delete servers with scope switching
|
|
10
|
-
- **Config Hierarchy**: Global defaults with project-level overrides
|
|
11
|
-
- **Auto-Discovery**: Tools from MCP servers are automatically registered as pi tools
|
|
12
|
-
- **Offline Support**: Bundled seed catalog with 49 curated servers as fallback
|
|
5
|
+
The add command opens a split-pane overlay: server browser on the left, JSON config editor on the right. Pick a server, edit its config, save. Tools from added servers are automatically registered as Pi tools with the pattern `{serverName}__{toolName}`.
|
|
13
6
|
|
|
14
7
|
## Commands
|
|
15
8
|
|
|
16
9
|
| Command | Description |
|
|
17
10
|
|---------|-------------|
|
|
18
|
-
| `/unipi:mcp-add` | Open browse
|
|
11
|
+
| `/unipi:mcp-add` | Open browse and editor overlay to add MCP servers |
|
|
19
12
|
| `/unipi:mcp-settings` | Interactive settings with enable/disable/edit |
|
|
20
13
|
| `/unipi:mcp-sync` | Force sync server catalog from GitHub |
|
|
21
14
|
| `/unipi:mcp-status` | Text summary of all configured servers |
|
|
22
15
|
|
|
23
|
-
|
|
16
|
+
### Setup Flow
|
|
17
|
+
|
|
18
|
+
1. Run `/unipi:mcp-add`
|
|
19
|
+
2. Browse or search the server catalog
|
|
20
|
+
3. Edit the config in the right pane
|
|
21
|
+
4. Save and restart Pi to activate
|
|
22
|
+
|
|
23
|
+
## Special Triggers
|
|
24
|
+
|
|
25
|
+
When MCP is installed, all workflow skills get access to MCP server tools. Tools are named `{serverName}__{toolName}` — for example, `github__search_code` or `filesystem__read_file`.
|
|
24
26
|
|
|
25
|
-
|
|
26
|
-
2. Add MCP servers via `/unipi:mcp-add` or manually edit config files
|
|
27
|
-
3. Restart pi to activate newly added servers
|
|
27
|
+
MCP registers with the info-screen dashboard, showing server count, active servers, and total tools. The footer subscribes to `MCP_SERVER_STARTED`, `MCP_SERVER_STOPPED`, and `MCP_SERVER_ERROR` events to display MCP status.
|
|
28
28
|
|
|
29
|
-
##
|
|
29
|
+
## Agent Tools
|
|
30
|
+
|
|
31
|
+
MCP tools are registered dynamically based on configured servers. Once a server is added and Pi restarts, its tools become available to the agent.
|
|
32
|
+
|
|
33
|
+
Example tool calls:
|
|
34
|
+
```
|
|
35
|
+
github__search_code({ query: "authentication middleware" })
|
|
36
|
+
github__list_pull_requests({ state: "open" })
|
|
37
|
+
filesystem__read_file({ path: "/home/user/config.json" })
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
The agent doesn't need to know about MCP directly — tools appear in its tool list with the server prefix.
|
|
41
|
+
|
|
42
|
+
## Configurables
|
|
30
43
|
|
|
31
44
|
### File Locations
|
|
32
45
|
|
|
@@ -63,47 +76,21 @@ MCP (Model Context Protocol) server management extension for Pi coding agent. Br
|
|
|
63
76
|
|
|
64
77
|
### Config Merge Rules
|
|
65
78
|
|
|
66
|
-
1. Server exists only in global
|
|
67
|
-
2. Server exists only in project
|
|
68
|
-
3. Server exists in both
|
|
69
|
-
4. `"enabled": false` in project metadata
|
|
79
|
+
1. Server exists only in global — loaded normally
|
|
80
|
+
2. Server exists only in project — loaded normally
|
|
81
|
+
3. Server exists in both — project wins entirely
|
|
82
|
+
4. `"enabled": false` in project metadata — disabled even if defined globally
|
|
70
83
|
|
|
71
|
-
##
|
|
84
|
+
## Troubleshooting
|
|
72
85
|
|
|
73
|
-
|
|
74
|
-
- `github__search_code`
|
|
75
|
-
- `filesystem__read_file`
|
|
76
|
-
- `brave-search__brave_web_search`
|
|
86
|
+
**Server won't start:** Check `/unipi:mcp-status` for errors, verify the command exists on your system.
|
|
77
87
|
|
|
78
|
-
|
|
88
|
+
**Tools not appearing:** Ensure the server is running and supports the MCP protocol.
|
|
79
89
|
|
|
80
|
-
|
|
81
|
-
packages/mcp/
|
|
82
|
-
├── src/
|
|
83
|
-
│ ├── index.ts # Extension entry, command registration
|
|
84
|
-
│ ├── types.ts # TypeScript interfaces
|
|
85
|
-
│ ├── config/
|
|
86
|
-
│ │ ├── schema.ts # Defaults and validation
|
|
87
|
-
│ │ ├── manager.ts # Config read/merge/write
|
|
88
|
-
│ │ └── sync.ts # Catalog fetch and caching
|
|
89
|
-
│ ├── bridge/
|
|
90
|
-
│ │ ├── client.ts # MCP JSON-RPC client (stdio)
|
|
91
|
-
│ │ ├── translator.ts # MCP tool → pi tool
|
|
92
|
-
│ │ └── registry.ts # Server lifecycle management
|
|
93
|
-
│ └── tui/
|
|
94
|
-
│ ├── add-overlay.ts # /unipi:mcp-add UI
|
|
95
|
-
│ └── settings-overlay.ts # /unipi:mcp-settings UI
|
|
96
|
-
├── data/
|
|
97
|
-
│ └── seed-servers.json # Offline fallback catalog (49 servers)
|
|
98
|
-
├── skills/mcp/
|
|
99
|
-
│ └── SKILL.md # Agent instructions
|
|
100
|
-
├── package.json
|
|
101
|
-
└── README.md
|
|
102
|
-
```
|
|
90
|
+
**Config issues:** Validate JSON syntax and check file permissions.
|
|
103
91
|
|
|
104
|
-
|
|
92
|
+
**Sync issues:** Run `/unipi:mcp-sync`, check network. The seed catalog (49 servers) is available offline as fallback.
|
|
93
|
+
|
|
94
|
+
## License
|
|
105
95
|
|
|
106
|
-
|
|
107
|
-
- **Tools not appearing**: Ensure server is running, check MCP protocol support
|
|
108
|
-
- **Config issues**: Validate JSON syntax, check file permissions
|
|
109
|
-
- **Sync issues**: Run `/unipi:mcp-sync`, check network, seed catalog available offline
|
|
96
|
+
MIT
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Registers commands, handles session lifecycle, wires up MCP server management.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
7
|
+
import type { ExtensionAPI, ExtensionCommandContext } from "@mariozechner/pi-coding-agent";
|
|
8
8
|
import {
|
|
9
9
|
UNIPI_EVENTS,
|
|
10
10
|
MODULES,
|
|
@@ -27,8 +27,7 @@ let registry: ServerRegistry | null = null;
|
|
|
27
27
|
|
|
28
28
|
/** Get info registry from global */
|
|
29
29
|
function getInfoRegistry() {
|
|
30
|
-
|
|
31
|
-
return g.__unipi_info_registry;
|
|
30
|
+
return globalThis.__unipi_info_registry;
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
/** Get the server registry (for commands) */
|
|
@@ -178,7 +177,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
178
177
|
// /unipi:mcp-status — text summary of all servers
|
|
179
178
|
pi.registerCommand(`unipi:${MCP_COMMANDS.STATUS}`, {
|
|
180
179
|
description: "Show status of all configured MCP servers",
|
|
181
|
-
handler: async (_args: string, ctx:
|
|
180
|
+
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
182
181
|
const reg = getRegistry();
|
|
183
182
|
if (!reg) {
|
|
184
183
|
ctx.ui.notify("MCP extension not initialized", "warning");
|
|
@@ -226,7 +225,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
226
225
|
// /unipi:mcp-sync — force catalog sync
|
|
227
226
|
pi.registerCommand(`unipi:${MCP_COMMANDS.SYNC}`, {
|
|
228
227
|
description: "Sync MCP server catalog from GitHub",
|
|
229
|
-
handler: async (_args: string, ctx:
|
|
228
|
+
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
230
229
|
try {
|
|
231
230
|
ctx.ui.notify("Syncing MCP catalog from GitHub...", "info");
|
|
232
231
|
const catalog = await syncCatalog();
|
|
@@ -250,7 +249,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
250
249
|
// /unipi:mcp-add — add server overlay
|
|
251
250
|
pi.registerCommand(`unipi:${MCP_COMMANDS.ADD}`, {
|
|
252
251
|
description: "Add an MCP server (browse catalog or custom config)",
|
|
253
|
-
handler: async (_args: string, ctx:
|
|
252
|
+
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
254
253
|
if (!ctx.hasUI) {
|
|
255
254
|
ctx.ui.notify("MCP Add requires an interactive UI.", "warning");
|
|
256
255
|
return;
|
|
@@ -278,7 +277,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
278
277
|
// /unipi:mcp-settings — settings overlay
|
|
279
278
|
pi.registerCommand(`unipi:${MCP_COMMANDS.SETTINGS}`, {
|
|
280
279
|
description: "Manage MCP server settings",
|
|
281
|
-
handler: async (_args: string, ctx:
|
|
280
|
+
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
282
281
|
if (!ctx.hasUI) {
|
|
283
282
|
ctx.ui.notify("MCP Settings requires an interactive UI.", "warning");
|
|
284
283
|
return;
|
|
@@ -312,7 +311,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
312
311
|
// /unipi:mcp-reload — restart all MCP servers
|
|
313
312
|
pi.registerCommand(`unipi:${MCP_COMMANDS.RELOAD}`, {
|
|
314
313
|
description: "Reload all MCP servers (restart with current config)",
|
|
315
|
-
handler: async (_args: string, ctx:
|
|
314
|
+
handler: async (_args: string, ctx: ExtensionCommandContext) => {
|
|
316
315
|
const reg = getRegistry();
|
|
317
316
|
if (!reg) {
|
|
318
317
|
ctx.ui.notify("MCP extension not initialized", "warning");
|
package/src/tui/add-overlay.ts
CHANGED
|
@@ -16,8 +16,10 @@ import {
|
|
|
16
16
|
Key,
|
|
17
17
|
matchesKey,
|
|
18
18
|
truncateToWidth,
|
|
19
|
+
type TUI,
|
|
19
20
|
visibleWidth,
|
|
20
21
|
} from "@mariozechner/pi-tui";
|
|
22
|
+
import type { Theme, KeybindingsManager } from "@mariozechner/pi-coding-agent";
|
|
21
23
|
import type { CatalogEntry, CatalogData, McpConfig, McpMetadata } from "../types.js";
|
|
22
24
|
import { loadCatalog } from "../config/sync.js";
|
|
23
25
|
import {
|
|
@@ -106,9 +108,9 @@ export function renderMcpAddOverlay(params?: {
|
|
|
106
108
|
onComplete?: () => void;
|
|
107
109
|
}) {
|
|
108
110
|
return (
|
|
109
|
-
tui:
|
|
110
|
-
theme:
|
|
111
|
-
_kb:
|
|
111
|
+
tui: TUI,
|
|
112
|
+
theme: Theme,
|
|
113
|
+
_kb: KeybindingsManager,
|
|
112
114
|
done: (result: { saved: boolean } | null) => void,
|
|
113
115
|
) => {
|
|
114
116
|
const scope = params?.scope ?? "global";
|
|
@@ -141,13 +143,13 @@ export function renderMcpAddOverlay(params?: {
|
|
|
141
143
|
}
|
|
142
144
|
|
|
143
145
|
const editorTheme: EditorTheme = {
|
|
144
|
-
borderColor: (s:
|
|
146
|
+
borderColor: (s: string) => theme.fg("accent", s),
|
|
145
147
|
selectList: {
|
|
146
|
-
selectedPrefix: (t:
|
|
147
|
-
selectedText: (t:
|
|
148
|
-
description: (t:
|
|
149
|
-
scrollInfo: (t:
|
|
150
|
-
noMatch: (t:
|
|
148
|
+
selectedPrefix: (t: string) => theme.fg("accent", t),
|
|
149
|
+
selectedText: (t: string) => theme.fg("accent", t),
|
|
150
|
+
description: (t: string) => theme.fg("muted", t),
|
|
151
|
+
scrollInfo: (t: string) => theme.fg("dim", t),
|
|
152
|
+
noMatch: (t: string) => theme.fg("warning", t),
|
|
151
153
|
},
|
|
152
154
|
};
|
|
153
155
|
const editor = new Editor(tui, editorTheme);
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* edit, delete, scope switching, and sync trigger.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { Key, matchesKey, truncateToWidth, visibleWidth } from "@mariozechner/pi-tui";
|
|
8
|
+
import { Key, matchesKey, truncateToWidth, type TUI, visibleWidth } from "@mariozechner/pi-tui";
|
|
9
|
+
import type { Theme, KeybindingsManager } from "@mariozechner/pi-coding-agent";
|
|
9
10
|
import type { ServerState } from "../types.js";
|
|
10
11
|
import {
|
|
11
12
|
loadMcpConfig,
|
|
@@ -49,9 +50,9 @@ export function renderMcpSettingsOverlay(params?: {
|
|
|
49
50
|
onComplete?: () => void;
|
|
50
51
|
}) {
|
|
51
52
|
return (
|
|
52
|
-
tui:
|
|
53
|
-
theme:
|
|
54
|
-
_kb:
|
|
53
|
+
tui: TUI,
|
|
54
|
+
theme: Theme,
|
|
55
|
+
_kb: KeybindingsManager,
|
|
55
56
|
done: (result: { action?: string } | null) => void,
|
|
56
57
|
) => {
|
|
57
58
|
const registry = params?.registry;
|