@qusic/pi-dynamic-mcp 0.0.0 → 0.20261016.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bang Lee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,45 +1,11 @@
1
- # @qusic/pi-dynamic-mcp
1
+ # Pi extensions
2
2
 
3
- ## ⚠️ IMPORTANT NOTICE ⚠️
3
+ Small [Pi](https://github.com/earendil-works/pi) extensions for personal use, published separately for easy installation across machines.
4
4
 
5
- **This package is created solely for the purpose of setting up OIDC (OpenID Connect) trusted publishing with npm.**
6
-
7
- This is **NOT** a functional package and contains **NO** code or functionality beyond the OIDC setup configuration.
8
-
9
- ## Purpose
10
-
11
- This package exists to:
12
- 1. Configure OIDC trusted publishing for the package name `@qusic/pi-dynamic-mcp`
13
- 2. Enable secure, token-less publishing from CI/CD workflows
14
- 3. Establish provenance for packages published under this name
15
-
16
- ## What is OIDC Trusted Publishing?
17
-
18
- OIDC trusted publishing allows package maintainers to publish packages directly from their CI/CD workflows without needing to manage npm access tokens. Instead, it uses OpenID Connect to establish trust between the CI/CD provider (like GitHub Actions) and npm.
19
-
20
- ## Setup Instructions
21
-
22
- To properly configure OIDC trusted publishing for this package:
23
-
24
- 1. Go to [npmjs.com](https://www.npmjs.com/) and navigate to your package settings
25
- 2. Configure the trusted publisher (e.g., GitHub Actions)
26
- 3. Specify the repository and workflow that should be allowed to publish
27
- 4. Use the configured workflow to publish your actual package
28
-
29
- ## DO NOT USE THIS PACKAGE
30
-
31
- This package is a placeholder for OIDC configuration only. It:
32
- - Contains no executable code
33
- - Provides no functionality
34
- - Should not be installed as a dependency
35
- - Exists only for administrative purposes
36
-
37
- ## More Information
38
-
39
- For more details about npm's trusted publishing feature, see:
40
- - [npm Trusted Publishing Documentation](https://docs.npmjs.com/generating-provenance-statements)
41
- - [GitHub Actions OIDC Documentation](https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/about-security-hardening-with-openid-connect)
42
-
43
- ---
44
-
45
- **Maintained for OIDC setup purposes only**
5
+ | Extension | npm | Install | Description |
6
+ | --- | --- | --- | --- |
7
+ | [compact-filter](./compact-filter.ts) | [![npm](https://img.shields.io/npm/v/%40qusic%2Fpi-compact-filter)](https://www.npmjs.com/package/@qusic/pi-compact-filter) | `pi install npm:@qusic/pi-compact-filter` | Keep Pi compaction file lists scoped to the current summary window. |
8
+ | [copilot-sync](./copilot-sync.ts) | [![npm](https://img.shields.io/npm/v/%40qusic%2Fpi-copilot-sync)](https://www.npmjs.com/package/@qusic/pi-copilot-sync) | `pi install npm:@qusic/pi-copilot-sync` | Sync live GitHub Copilot model capabilities into Pi. |
9
+ | [copilot2api](./copilot2api.ts) | [![npm](https://img.shields.io/npm/v/%40qusic%2Fpi-copilot2api)](https://www.npmjs.com/package/@qusic/pi-copilot2api) | `pi install npm:@qusic/pi-copilot2api` | Add copilot2api as a native Pi provider with live model discovery. |
10
+ | [dynamic-mcp](./dynamic-mcp.ts) | [![npm](https://img.shields.io/npm/v/%40qusic%2Fpi-dynamic-mcp)](https://www.npmjs.com/package/@qusic/pi-dynamic-mcp) | `pi install npm:@qusic/pi-dynamic-mcp` | Dynamically manage MCP servers for the current Pi session. |
11
+ | [session-trim](./session-trim.ts) | [![npm](https://img.shields.io/npm/v/%40qusic%2Fpi-session-trim)](https://www.npmjs.com/package/@qusic/pi-session-trim) | `pi install npm:@qusic/pi-session-trim` | Speed up loading large Pi sessions by pruning superseded history. |
package/dynamic-mcp.ts ADDED
@@ -0,0 +1,64 @@
1
+ // npm-description: Dynamically manage MCP servers for the current Pi session.
2
+ // npm-keywords: mcp, model-context-protocol, dynamic-mcp, session-scoped, stdio, streamable-http
3
+
4
+ import { isDeepStrictEqual } from "node:util";
5
+ import { StringEnum, Type } from "@earendil-works/pi-ai";
6
+ import type { ExtensionAPI, McpServerConfig } from "@earendil-works/pi-coding-agent";
7
+
8
+ // Pi's McpServerConfig and validator: https://github.com/earendil-works/pi/blob/main/packages/coding-agent/src/core/mcp-servers.ts
9
+ // This model-facing subset is validated again by registerMcpServer.
10
+ const parameters = Type.Object({
11
+ action: StringEnum(["add", "remove", "list"] as const),
12
+ name: Type.Optional(Type.String({ description: "Server name for add or remove" })),
13
+ config: Type.Optional(
14
+ Type.Object({
15
+ command: Type.Optional(Type.String({ description: "Stdio executable, not a shell command" })),
16
+ args: Type.Optional(Type.Array(Type.String())),
17
+ cwd: Type.Optional(Type.String()),
18
+ env: Type.Optional(Type.Record(Type.String(), Type.String())),
19
+ url: Type.Optional(Type.String({ description: "Streamable HTTP URL" })),
20
+ headers: Type.Optional(Type.Record(Type.String(), Type.String())),
21
+ description: Type.Optional(Type.String()),
22
+ timeout: Type.Optional(Type.Number()),
23
+ }),
24
+ ),
25
+ });
26
+
27
+ export default function (pi: ExtensionAPI) {
28
+ const managed = new Map<string, McpServerConfig>();
29
+
30
+ pi.registerTool({
31
+ name: "mcp",
32
+ label: "MCP",
33
+ description:
34
+ "Manage session MCP servers: add(name, config) with command/args (stdio) or url (HTTP), remove(name), or list(). list shows server configs managed by this tool, not connection status. env and headers support ${VAR}.",
35
+ parameters,
36
+ async execute(_id, { action, name, config }) {
37
+ let text: string;
38
+ if (action === "list") {
39
+ text = JSON.stringify(Object.fromEntries(managed), null, 2);
40
+ } else if (!name) {
41
+ throw new Error("Server name is required");
42
+ } else if (action === "remove") {
43
+ if (!managed.has(name)) throw new Error(`Server "${name}" is not managed by this tool`);
44
+ pi.unregisterMcpServer(name);
45
+ managed.delete(name);
46
+ text = `Removed "${name}"`;
47
+ } else {
48
+ if (!config || Boolean(config.command) === Boolean(config.url)) {
49
+ throw new Error("Provide exactly one of command (stdio) or url (HTTP) in config");
50
+ }
51
+ const common = { description: config.description, timeout: config.timeout };
52
+ const serverConfig: McpServerConfig = config.url
53
+ ? { ...common, url: config.url, headers: config.headers }
54
+ : { ...common, command: config.command!, args: config.args, cwd: config.cwd, env: config.env };
55
+ const duplicate = [...managed].find(([, existing]) => isDeepStrictEqual(existing, serverConfig));
56
+ if (duplicate) throw new Error(`Server "${duplicate[0]}" is already registered with an identical config`);
57
+ pi.registerMcpServer(name, serverConfig);
58
+ managed.set(name, structuredClone(serverConfig));
59
+ text = `Registered "${name}". Use codemode to find and call its tools.`;
60
+ }
61
+ return { content: [{ type: "text", text }], details: undefined };
62
+ },
63
+ });
64
+ }
package/package.json CHANGED
@@ -1,10 +1,37 @@
1
1
  {
2
- "name": "@qusic/pi-dynamic-mcp",
3
- "version": "0.0.0",
4
- "description": "OIDC trusted publishing setup package for @qusic/pi-dynamic-mcp",
5
- "keywords": [
6
- "oidc",
7
- "trusted-publishing",
8
- "setup"
9
- ]
2
+ "name": "@qusic/pi-dynamic-mcp",
3
+ "version": "0.20261016.0",
4
+ "homepage": "https://github.com/Qusic/pi-extensions#readme",
5
+ "bugs": {
6
+ "url": "https://github.com/Qusic/pi-extensions/issues"
7
+ },
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/Qusic/pi-extensions.git"
11
+ },
12
+ "license": "MIT",
13
+ "type": "module",
14
+ "pi": {
15
+ "extensions": [
16
+ "./*.ts"
17
+ ]
18
+ },
19
+ "peerDependencies": {
20
+ "@earendil-works/pi-ai": "*",
21
+ "@earendil-works/pi-agent-core": "*",
22
+ "@earendil-works/pi-coding-agent": "*"
23
+ },
24
+ "description": "Dynamically manage MCP servers for the current Pi session.",
25
+ "keywords": [
26
+ "pi-package",
27
+ "pi-extension",
28
+ "pi",
29
+ "pi-coding-agent",
30
+ "mcp",
31
+ "model-context-protocol",
32
+ "dynamic-mcp",
33
+ "session-scoped",
34
+ "stdio",
35
+ "streamable-http"
36
+ ]
10
37
  }