mono-pilot 0.2.8 → 0.2.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.
@@ -1,7 +1,7 @@
1
- import { homedir } from "node:os";
2
- import { resolve } from "node:path";
3
1
  import { Type } from "@sinclair/typebox";
4
- import { createRpcRequestId, extractStringHeaders, formatErrorMessage, formatJsonRpcError, inferTransport, isRecord, isServerEnabled, MCP_CONFIG_RELATIVE_PATH, parseMcpConfig, postJsonRpcRequest, resolveMcpConfigPath, toNonEmptyString, initializeMcpSession, } from "../src/utils/mcp-client.js";
2
+ import { resolveTargetServers } from "../src/mcp/servers.js";
3
+ import { createRpcRequestId, formatJsonRpcError, initializeMcpSession, postJsonRpcRequest } from "../src/mcp/protocol.js";
4
+ import { formatErrorMessage, isRecord, toNonEmptyString } from "../src/mcp/config.js";
5
5
  const DESCRIPTION = `List available MCP tools from configured MCP servers. Each returned tool includes server metadata. If server is provided, results are limited to that server. If toolName is provided, returns full documentation and input JSON schema for matching tools.`;
6
6
  const listMcpToolsSchema = Type.Object({
7
7
  server: Type.Optional(Type.String({
@@ -44,16 +44,9 @@ async function listRemoteMcpTools(options) {
44
44
  const name = toNonEmptyString(raw.name);
45
45
  if (!name)
46
46
  continue;
47
- tools.push({
48
- name,
49
- description: toNonEmptyString(raw.description),
50
- inputSchema: raw.inputSchema,
51
- });
47
+ tools.push({ name, description: toNonEmptyString(raw.description), inputSchema: raw.inputSchema });
52
48
  }
53
- return {
54
- tools,
55
- nextCursor: toNonEmptyString(body.result.nextCursor),
56
- };
49
+ return { tools, nextCursor: toNonEmptyString(body.result.nextCursor) };
57
50
  }
58
51
  function normalizeOptionalString(value) {
59
52
  if (typeof value !== "string")
@@ -68,11 +61,14 @@ export default function listMcpToolsExtension(pi) {
68
61
  description: DESCRIPTION,
69
62
  parameters: listMcpToolsSchema,
70
63
  async execute(toolCallId, params, signal, _onUpdate, ctx) {
71
- let serverFilter;
72
- let toolNameFilter;
64
+ const serverFilter = normalizeOptionalString(params.server);
65
+ const toolNameFilter = normalizeOptionalString(params.toolName);
66
+ let targetServers;
67
+ let sources;
73
68
  try {
74
- serverFilter = normalizeOptionalString(params.server);
75
- toolNameFilter = normalizeOptionalString(params.toolName);
69
+ const result = await resolveTargetServers(ctx.cwd, serverFilter);
70
+ targetServers = result.servers;
71
+ sources = result.sources;
76
72
  }
77
73
  catch (error) {
78
74
  const message = formatErrorMessage(error);
@@ -82,49 +78,6 @@ export default function listMcpToolsExtension(pi) {
82
78
  isError: true,
83
79
  };
84
80
  }
85
- const configPath = resolveMcpConfigPath(ctx.cwd);
86
- if (!configPath) {
87
- const workspaceCandidate = resolve(ctx.cwd, MCP_CONFIG_RELATIVE_PATH);
88
- const homeCandidate = resolve(homedir(), MCP_CONFIG_RELATIVE_PATH);
89
- const message = `MCP config not found. Checked:\n- ${workspaceCandidate}\n- ${homeCandidate}`;
90
- return {
91
- content: [{ type: "text", text: message }],
92
- details: { error: message },
93
- isError: true,
94
- };
95
- }
96
- let servers;
97
- try {
98
- servers = await parseMcpConfig(configPath);
99
- }
100
- catch (error) {
101
- const message = formatErrorMessage(error);
102
- return {
103
- content: [{ type: "text", text: message }],
104
- details: {
105
- config_path: configPath,
106
- error: message,
107
- },
108
- isError: true,
109
- };
110
- }
111
- const targetServers = [];
112
- for (const [serverName, serverConfig] of Object.entries(servers)) {
113
- if (serverFilter && serverName !== serverFilter)
114
- continue;
115
- if (!isServerEnabled(serverConfig))
116
- continue;
117
- if (inferTransport(serverConfig) !== "remote")
118
- continue;
119
- const serverUrl = toNonEmptyString(serverConfig.url);
120
- if (!serverUrl)
121
- continue;
122
- targetServers.push({
123
- name: serverName,
124
- url: serverUrl,
125
- headers: extractStringHeaders(serverConfig.headers),
126
- });
127
- }
128
81
  if (targetServers.length === 0) {
129
82
  const message = serverFilter
130
83
  ? `No active remote MCP server found matching '${serverFilter}'.`
@@ -132,13 +85,16 @@ export default function listMcpToolsExtension(pi) {
132
85
  return {
133
86
  content: [{ type: "text", text: message }],
134
87
  details: {
135
- config_path: configPath,
88
+ config_paths: sources.map((s) => s.path),
136
89
  servers_matched: 0,
137
90
  },
138
91
  };
139
92
  }
140
93
  const lines = [];
141
- lines.push(`MCP config: ${configPath}`);
94
+ lines.push("MCP config:");
95
+ for (const source of sources) {
96
+ lines.push(`- ${source.scope}: ${source.path}`);
97
+ }
142
98
  lines.push(`Servers matched: ${targetServers.length}`);
143
99
  if (serverFilter)
144
100
  lines.push(`Server filter: ${serverFilter}`);
@@ -167,7 +123,6 @@ export default function listMcpToolsExtension(pi) {
167
123
  continue;
168
124
  }
169
125
  if (toolNameFilter) {
170
- // Detailed mode
171
126
  for (const tool of matchedTools) {
172
127
  totalTools++;
173
128
  lines.push(`## [${target.name}] ${tool.name}`);
@@ -187,7 +142,6 @@ export default function listMcpToolsExtension(pi) {
187
142
  }
188
143
  }
189
144
  else {
190
- // Summary mode
191
145
  lines.push(`Tools returned: ${matchedTools.length}`);
192
146
  lines.push("");
193
147
  for (const tool of matchedTools) {
@@ -218,7 +172,7 @@ export default function listMcpToolsExtension(pi) {
218
172
  return {
219
173
  content: [{ type: "text", text: lines.join("\n").trim() }],
220
174
  details: {
221
- config_path: configPath,
175
+ config_paths: sources.map((s) => s.path),
222
176
  servers_matched: targetServers.length,
223
177
  servers_queried: targetServers.length,
224
178
  servers_failed: serversFailed,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mono-pilot",
3
- "version": "0.2.8",
3
+ "version": "0.2.10",
4
4
  "description": "Cursor-compatible coding agent powered by pi-mono",
5
5
  "type": "module",
6
6
  "license": "MIT",