@jangmanj/mcp 0.12.3 → 0.14.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 CHANGED
@@ -292,8 +292,8 @@ Pi as `mcp__<server>__<tool>`.
292
292
  ```sh
293
293
  pi install npm:@jangmanj/mcp
294
294
  # or from a checkout / git ref:
295
- pi install ./path/to/mcp-client
296
- pi install git:github.com/JangMan-J/mcp-client@v0.1.1
295
+ pi install ./path/to/mcp
296
+ pi install git:github.com/JangMan-J/mcp-client@v0.13.0
297
297
  ```
298
298
 
299
299
  The extension reads the same `mcp.json` files as built-in MCP
@@ -310,13 +310,14 @@ Beyond tools, it covers built-in MCP parity: `list_mcp_resources`,
310
310
  tool updates, `/mcp prompts|prompt|resources|task|enable|disable|exposure`
311
311
  subcommands, MRTR elicitation through Pi's UI, task handles with `tasks/get`
312
312
  and `tasks/cancel`, 20 KB middle-out text truncation with temp-file offload,
313
- and a rotating `$PI_CODING_AGENT_DIR/mcp-client.log`.
313
+ and a rotating `$PI_CODING_AGENT_DIR/mcp.log`.
314
314
 
315
315
  OAuth works out of the box for HTTP servers without a static `Authorization` header: the
316
316
  first 401 marks the server "needs sign-in" in `/mcp`, and `/mcp login <name>` runs the
317
317
  authorization-code + PKCE flow with CIMD/DCR registration through the system browser.
318
- Credentials persist in `$PI_CODING_AGENT_DIR/mcp-client-oauth.json` (issuer-keyed);
319
- `/mcp logout <name>` deletes them. The full `oauth` config shape is supported:
318
+ Credentials persist in `$PI_CODING_AGENT_DIR/mcp-oauth.json` (issuer-keyed);
319
+ `/mcp logout <name>` deletes them. Earlier versions stored them in
320
+ `mcp-client-oauth.json`; rename that file once to keep existing sign-ins. The full `oauth` config shape is supported:
320
321
  `clientId`, `clientSecret`, `clientName`, `callbackPort`, `callbackUrl` (loopback HTTP),
321
322
  `scope` (space-separated, merged with advertised scopes), and `authServerMetadataUrl`
322
323
  (trusted as configured, skips PRM discovery).
@@ -5,18 +5,18 @@
5
5
  */
6
6
 
7
7
  import { createHash } from "node:crypto";
8
- import { McpClient } from "../../dist/index.js";
8
+ import { McpClient } from "@jangmanj/mcp/core";
9
9
  import {
10
10
  createOps,
11
11
  normalizeContent,
12
12
  type Ops,
13
13
  type ToolCallResult,
14
14
  type ToolEntry,
15
- } from "../../dist/ops/index.js";
16
- import { HttpTransport } from "../../dist/transport-http/index.js";
17
- import { StdioTransport } from "../../dist/transport-stdio/index.js";
18
- import { createTasksExtension } from "../../dist/mrtr-cache/index.js";
19
- import type { Outcome } from "../../dist/index.js";
15
+ } from "@jangmanj/mcp/ops";
16
+ import { HttpTransport } from "@jangmanj/mcp/transport-http";
17
+ import { StdioTransport } from "@jangmanj/mcp/transport-stdio";
18
+ import { createTasksExtension } from "@jangmanj/mcp/mrtr-cache";
19
+ import type { Outcome } from "@jangmanj/mcp/core";
20
20
  import type { Exposure, ResolvedServerConfig } from "./config.ts";
21
21
  import { convertBlocksOffloaded } from "./content-offloaded.ts";
22
22
  import { DiagnosticsLog } from "./diagnostics.ts";
@@ -184,7 +184,7 @@ export interface BridgeOptions {
184
184
  readonly allowInsecureAuth?: boolean;
185
185
  /** Host UI for elicitation prompts; without it elicitations decline. */
186
186
  readonly ui?: Ui;
187
- /** Diagnostics log path (mcp-client.log). */
187
+ /** Diagnostics log path (mcp.log). */
188
188
  readonly diagnosticsLogPath?: string;
189
189
  }
190
190
 
@@ -394,7 +394,7 @@ export class McpBridge {
394
394
  const client = new McpClient({
395
395
  transport,
396
396
  server: { key: config.name, label: config.name },
397
- clientInfo: { name: "pi", version: "mcp-client-bridge" },
397
+ clientInfo: { name: "pi", version: "pi-adapter" },
398
398
  defaults: { timeoutMs: config.timeoutMs },
399
399
  ports: { consent: consentPort(this.ui, config.name) },
400
400
  });
@@ -1,6 +1,6 @@
1
1
  /** Async content conversion with built-in MCP's 20 KB middle-out truncation. */
2
2
 
3
- import type { ContentBlock } from "../../dist/ops/index.js";
3
+ import type { ContentBlock } from "@jangmanj/mcp/ops";
4
4
  import type { PiContent } from "./pi-api.ts";
5
5
  import { offloadBinary, offloadText } from "./result-files.ts";
6
6
 
@@ -7,7 +7,7 @@
7
7
  * text description so the model always sees something.
8
8
  */
9
9
 
10
- import type { ContentBlock } from "../../dist/ops/index.js";
10
+ import type { ContentBlock } from "@jangmanj/mcp/ops";
11
11
  import type { PiContent } from "./pi-api.ts";
12
12
 
13
13
  /** Per-text-block cap, matching Pi's generic tool-output limit of ~50 KB. */
@@ -1,4 +1,4 @@
1
- /** Bounded diagnostics log (mcp-client.log), rotated at 5 MB like Pi's mcp.log. */
1
+ /** Bounded diagnostics log (mcp.log), rotated at 5 MB like Pi's mcp.log. */
2
2
 
3
3
  import { appendFile, mkdir, rename, stat } from "node:fs/promises";
4
4
  import { dirname } from "node:path";
@@ -1,10 +1,10 @@
1
1
  /** MRTR + elicitation support using the host's Pi UI. */
2
2
 
3
- import { openSystemBrowser } from "../../dist/auth/index.js";
4
- import type { Outcome } from "../../dist/index.js";
5
- import type { ConsentPort } from "../../dist/index.js";
6
- import { elicit, type FormRequest } from "../../dist/mrtr-cache/index.js";
7
- import { normalizeContent, type ToolCallResult } from "../../dist/ops/index.js";
3
+ import { openSystemBrowser } from "@jangmanj/mcp/auth";
4
+ import type { Outcome } from "@jangmanj/mcp/core";
5
+ import type { ConsentPort } from "@jangmanj/mcp/core";
6
+ import { elicit, type FormRequest } from "@jangmanj/mcp/mrtr-cache";
7
+ import { normalizeContent, type ToolCallResult } from "@jangmanj/mcp/ops";
8
8
  import type { ResourceServer } from "./resources.ts";
9
9
  import type { Ui } from "./pi-api.ts";
10
10
 
@@ -44,8 +44,8 @@ export default function (pi: ExtensionAPI) {
44
44
  const bridge = new McpBridge({
45
45
  pi,
46
46
  notify: (message, level) => currentUi?.notify(message, level),
47
- credentialStorePath: join(agentDir(process.env, homedir()), "mcp-client-oauth.json"),
48
- diagnosticsLogPath: join(agentDir(process.env, homedir()), "mcp-client.log"),
47
+ credentialStorePath: join(agentDir(process.env, homedir()), "mcp-oauth.json"),
48
+ diagnosticsLogPath: join(agentDir(process.env, homedir()), "mcp.log"),
49
49
  confirm: (title, message) => currentUi?.confirm?.(title, message) ?? Promise.resolve(false),
50
50
  ui: {
51
51
  notify: (message, level) => currentUi?.notify(message, level),
@@ -57,7 +57,7 @@ export default function (pi: ExtensionAPI) {
57
57
 
58
58
  // Registering /mcp replaces built-in MCP support for sessions.
59
59
  pi.registerCommand("mcp", {
60
- description: "MCP (mcp-client bridge): list, reconnect, login, logout, tools, prompts, resources, task, enable/disable, exposure",
60
+ description: "MCP (mcp bridge): list, reconnect, login, logout, tools, prompts, resources, task, enable/disable, exposure",
61
61
  handler: async (args, ctx) => {
62
62
  const [sub, ...rest] = args.trim().split(/\s+/).filter(Boolean);
63
63
  const name = rest[0];
@@ -18,7 +18,7 @@ import {
18
18
  startLoopbackRedirect,
19
19
  type AuthorizationConsent,
20
20
  type ClientRegistration,
21
- } from "../../dist/auth/index.js";
21
+ } from "@jangmanj/mcp/auth";
22
22
  import type { ResolvedServerConfig } from "./config.ts";
23
23
 
24
24
  export {
@@ -1,8 +1,8 @@
1
1
  /** Built-in MCP resource tools: list_mcp_resources, list_mcp_resource_templates, read_mcp_resource. */
2
2
 
3
- import type { Outcome } from "../../dist/index.js";
4
- import type { McpClient } from "../../dist/index.js";
5
- import type { Ops } from "../../dist/ops/index.js";
3
+ import type { Outcome } from "@jangmanj/mcp/core";
4
+ import type { McpClient } from "@jangmanj/mcp/core";
5
+ import type { Ops } from "@jangmanj/mcp/ops";
6
6
  import type { Exposure } from "./config.ts";
7
7
  import { offloadBinary, offloadText } from "./result-files.ts";
8
8
  import type { ExtensionAPI, ToolResult } from "./pi-api.ts";
@@ -15,7 +15,7 @@ export interface OffloadedText {
15
15
  /** Middle-out truncation at 20 KB with the full text saved to a temp file. */
16
16
  export async function offloadText(text: string): Promise<OffloadedText> {
17
17
  if (text.length <= MAX_INLINE_TEXT) return { text };
18
- const filePath = join(tmpdir(), `mcp-client-${randomUUID()}.txt`);
18
+ const filePath = join(tmpdir(), `mcp-${randomUUID()}.txt`);
19
19
  await writeFile(filePath, text);
20
20
  const removed = text.length - MAX_INLINE_TEXT;
21
21
  const half = MAX_INLINE_TEXT / 2;
@@ -26,7 +26,7 @@ export async function offloadText(text: string): Promise<OffloadedText> {
26
26
  }
27
27
 
28
28
  export async function offloadBinary(bytes: Uint8Array, extension = "bin"): Promise<string> {
29
- const filePath = join(tmpdir(), `mcp-client-${randomUUID()}.${extension}`);
29
+ const filePath = join(tmpdir(), `mcp-${randomUUID()}.${extension}`);
30
30
  await writeFile(filePath, bytes);
31
31
  return filePath;
32
32
  }
@@ -1,9 +1,9 @@
1
1
  /** Task-based tool-call results and /mcp task helpers. */
2
2
 
3
- import type { Outcome } from "../../dist/index.js";
4
- import type { McpClient } from "../../dist/index.js";
5
- import { TasksRuntime, type TaskState } from "../../dist/mrtr-cache/index.js";
6
- import type { ToolCallResult } from "../../dist/ops/index.js";
3
+ import type { Outcome } from "@jangmanj/mcp/core";
4
+ import type { McpClient } from "@jangmanj/mcp/core";
5
+ import { TasksRuntime, type TaskState } from "@jangmanj/mcp/mrtr-cache";
6
+ import type { ToolCallResult } from "@jangmanj/mcp/ops";
7
7
  import type { ResourceServer } from "./resources.ts";
8
8
  import type { ToolResult } from "./pi-api.ts";
9
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jangmanj/mcp",
3
- "version": "0.12.3",
3
+ "version": "0.14.0",
4
4
  "description": "MCP 2026-07-28 client and server library: push events/subscriptions, core, transports, auth, ops, MRTR/cache, OTEL telemetry, and extensions.",
5
5
  "license": "MIT",
6
6
  "author": "JangMan-J",
@@ -1,65 +0,0 @@
1
- # Host touchpoints: pi-coding-agent vs other Pi modules
2
-
3
- This adapter is written against a structural `ExtensionAPI` (`pi-api.ts`), not
4
- imported Pi packages (the repo's `check-forbidden` rule forbids them). The
5
- following touchpoints are **pi-coding-agent-specific** and cannot be moved to
6
- `pi-ai`, `pi-codemode`, or `pi-durable` without a host adapter:
7
-
8
- | Touchpoint | Where | Why it is host-specific |
9
- |---|---|---|
10
- | `pi.registerTool` / `pi.registerCommand` | `bridge.ts`, `index.ts` | Tool/command ownership and `/mcp` replacement semantics belong to pi-coding-agent's extension runner. |
11
- | `exposure`, `namespace`, `annotations` | `bridge.ts` | These are pi-coding-agent's codemode/tool_search exposure model, not MCP concepts. |
12
- | `pi.getActiveTools` / `setActiveTools` / `getAllTools` | `bridge.ts` (`ensureReachTools`) | Activating `codemode` / `tool_search` is a pi-coding-agent tool-loadout operation. |
13
- | `before_agent_start` + `systemPromptOptions.sections` | `index.ts` | pi-coding-agent's system-prompt section model (`mcp_servers`). |
14
- | `tool_call` waits for late registration | `index.ts` | pi-coding-agent's tool pipeline and `reachesTools` behavior. |
15
- | `session_start` / `session_shutdown` / `mcp_servers_change` | `index.ts` | pi-coding-agent session lifecycle and `pi.registerMcpServer` registry. |
16
- | `ctx.ui.notify/confirm/input/select` | `index.ts`, `oauth.ts`, `elicitation.ts` | pi-coding-agent TUI prompts. |
17
- | `pi.getSettings().autoEnableCodemode` | `bridge.ts` | pi-coding-agent settings shape. |
18
-
19
- Portable as-is:
20
-
21
- - `PiContent` text/image blocks are structurally identical to `pi-ai`'s
22
- `TextContent` / `ImageContent`.
23
- - `config.ts` (mcp.json discovery/merge/interpolation) is host-neutral except
24
- for the `PI_CODING_AGENT_DIR` convention, which other hosts may mirror.
25
- - `bridge.ts`'s connection, OAuth, MRTR, resource, and result-conversion logic
26
- only needs the small `ExtensionAPI` surface above; a durable host can wrap it
27
- with its own `defineExtension`/`defineTool` adapter.
28
-
29
- `pi-durable` (cellar) uses `defineExtension`/`defineTool` with a different
30
- `execute(args, api, context)` signature and its own event delivery, so there is
31
- no drop-in move into durable; it needs the thin wrapper described above.
32
- Cellar also provides its own command registerer, so the `/mcp` command surface
33
- (`index.ts`) is portable there directly; the remaining durable-specific work is
34
- tool execution signatures, UI prompts, and session/event delivery.
35
-
36
- ## Cellar equivalents (graph: home-jangmanj-Projects-cellar, 2026-11-25)
37
-
38
- Mapped against `src/daemon/pi-extensions.ts` (indexed, no recorded coverage
39
- issue). Most of this adapter's pi-coding-agent surface has a direct durable
40
- equivalent:
41
-
42
- | Adapter touchpoint | Cellar equivalent |
43
- |---|---|
44
- | `pi.registerTool` | `PiExtensionApi.registerTool` / `PiTool` (same execute shape) |
45
- | `pi.registerCommand` | `pi-extensions.registerCommand` (UI doc commands) |
46
- | `exposure` | `PiTool.exposure` (string) |
47
- | `annotations` | `PiTool.annotations` |
48
- | `namespace` | **No equivalent** — `PiTool` has no namespace field; codemode grouping must be rethought or added. |
49
- | `getActiveTools` / `setActiveTools` / `getAllTools` | `pi-extensions.getActiveTools` / `setActiveTools` / `getAllTools` |
50
- | `before_agent_start` | `pi-extensions.beforeAgentStart` (systemPrompt override supported) |
51
- | `systemPromptOptions.sections` | **No equivalent** — `systemPromptOptions: {}` is passed empty; use `systemPrompt` override instead of an `mcp_servers` section. |
52
- | `tool_call` | `pi-extensions.beforeTool` (mutable input, block, gate prompts) |
53
- | `session_start` / `session_shutdown` | `pi-extensions.start` / `close` |
54
- | `mcp_servers_change` | **No event found** — `registerMcpServer` / `unregisterMcpServer` / `getMcpServers` exist, but no change event; re-read on demand. |
55
- | `ctx.ui.notify/confirm/input/select` | `pi-extensions.notify` / `confirm` / `input` / `select` |
56
- | `ctx.cwd` / `hasUI` / `isProjectTrusted` | `ExtensionContext.cwd` / `hasUI` / `isProjectTrusted` |
57
- | `pi.getSettings()` | `pi-extensions.getSettings` (merged settings; no `autoEnableCodemode` reference found) |
58
- | `pi.registerMcpServer` | `PiExtensionApi.registerMcpServer` |
59
-
60
- Net: a durable adapter can reuse nearly all of `bridge.ts` unchanged. The
61
- adapter-specific deltas are (1) no `namespace`, (2) system-prompt override
62
- instead of sections, (3) no `mcp_servers_change` event, and (4) no
63
- `autoEnableCodemode` setting lookup. `mcp-host.ts` / `mcp-events.ts` were not
64
- present in this moderate index generation; earlier full-index evidence had
65
- `startMcpHost` called by `src.cli.mcp` and `src.daemon.main.globalMcp` / `mcp`.