@mrpatronz/nexusflow 1.3.2 → 1.5.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 +50 -0
- package/dist/commands/create.d.ts.map +1 -1
- package/dist/commands/create.js +54 -37
- package/dist/commands/create.js.map +1 -1
- package/dist/commands/diff.d.ts.map +1 -1
- package/dist/commands/diff.js +16 -73
- package/dist/commands/diff.js.map +1 -1
- package/dist/commands/doctor.d.ts +4 -0
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +58 -318
- package/dist/commands/doctor.js.map +1 -1
- package/dist/commands/finish.d.ts +17 -0
- package/dist/commands/finish.d.ts.map +1 -0
- package/dist/commands/finish.js +172 -0
- package/dist/commands/finish.js.map +1 -0
- package/dist/commands/handoff.d.ts.map +1 -1
- package/dist/commands/handoff.js +11 -6
- package/dist/commands/handoff.js.map +1 -1
- package/dist/commands/knowledge.d.ts +36 -0
- package/dist/commands/knowledge.d.ts.map +1 -0
- package/dist/commands/knowledge.js +184 -0
- package/dist/commands/knowledge.js.map +1 -0
- package/dist/commands/open.d.ts.map +1 -1
- package/dist/commands/open.js +2 -4
- package/dist/commands/open.js.map +1 -1
- package/dist/core/commit.d.ts +41 -0
- package/dist/core/commit.d.ts.map +1 -0
- package/dist/core/commit.js +53 -0
- package/dist/core/commit.js.map +1 -0
- package/dist/core/config.d.ts +3 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +60 -32
- package/dist/core/config.js.map +1 -1
- package/dist/core/config.test.js +24 -0
- package/dist/core/config.test.js.map +1 -1
- package/dist/core/diff.d.ts +27 -0
- package/dist/core/diff.d.ts.map +1 -0
- package/dist/core/diff.js +50 -0
- package/dist/core/diff.js.map +1 -0
- package/dist/core/doctor.d.ts +34 -0
- package/dist/core/doctor.d.ts.map +1 -0
- package/dist/core/doctor.js +276 -0
- package/dist/core/doctor.js.map +1 -0
- package/dist/core/finish.d.ts +56 -0
- package/dist/core/finish.d.ts.map +1 -0
- package/dist/core/finish.js +121 -0
- package/dist/core/finish.js.map +1 -0
- package/dist/core/finish.test.d.ts +2 -0
- package/dist/core/finish.test.d.ts.map +1 -0
- package/dist/core/finish.test.js +110 -0
- package/dist/core/finish.test.js.map +1 -0
- package/dist/core/knowledge.d.ts +96 -0
- package/dist/core/knowledge.d.ts.map +1 -0
- package/dist/core/knowledge.js +299 -0
- package/dist/core/knowledge.js.map +1 -0
- package/dist/core/knowledge.test.d.ts +2 -0
- package/dist/core/knowledge.test.d.ts.map +1 -0
- package/dist/core/knowledge.test.js +157 -0
- package/dist/core/knowledge.test.js.map +1 -0
- package/dist/core/refresh.test.d.ts +2 -0
- package/dist/core/refresh.test.d.ts.map +1 -0
- package/dist/core/refresh.test.js +67 -0
- package/dist/core/refresh.test.js.map +1 -0
- package/dist/core/status.d.ts +45 -0
- package/dist/core/status.d.ts.map +1 -0
- package/dist/core/status.js +45 -0
- package/dist/core/status.js.map +1 -0
- package/dist/core/sync.test.d.ts +2 -0
- package/dist/core/sync.test.d.ts.map +1 -0
- package/dist/core/sync.test.js +86 -0
- package/dist/core/sync.test.js.map +1 -0
- package/dist/core/workspace.create.test.d.ts +2 -0
- package/dist/core/workspace.create.test.d.ts.map +1 -0
- package/dist/core/workspace.create.test.js +95 -0
- package/dist/core/workspace.create.test.js.map +1 -0
- package/dist/core/workspace.d.ts +9 -3
- package/dist/core/workspace.d.ts.map +1 -1
- package/dist/core/workspace.js +91 -13
- package/dist/core/workspace.js.map +1 -1
- package/dist/core/worktree.d.ts +11 -1
- package/dist/core/worktree.d.ts.map +1 -1
- package/dist/core/worktree.js +2 -0
- package/dist/core/worktree.js.map +1 -1
- package/dist/core/worktree.test.d.ts +2 -0
- package/dist/core/worktree.test.d.ts.map +1 -0
- package/dist/core/worktree.test.js +111 -0
- package/dist/core/worktree.test.js.map +1 -0
- package/dist/generators/base.js +1 -1
- package/dist/generators/index.d.ts +7 -0
- package/dist/generators/index.d.ts.map +1 -1
- package/dist/generators/index.js +4 -1
- package/dist/generators/index.js.map +1 -1
- package/dist/index.js +110 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +51 -282
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts +45 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +413 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +43 -26
- package/dist/server.js.map +1 -1
- package/dist/utils/debug.d.ts +17 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +25 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/detect-ai.d.ts +14 -6
- package/dist/utils/detect-ai.d.ts.map +1 -1
- package/dist/utils/detect-ai.js +22 -9
- package/dist/utils/detect-ai.js.map +1 -1
- package/dist/utils/detect-ai.test.js +33 -0
- package/dist/utils/detect-ai.test.js.map +1 -1
- package/dist/utils/git.d.ts +13 -2
- package/dist/utils/git.d.ts.map +1 -1
- package/dist/utils/git.js +64 -5
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/git.test.js +46 -8
- package/dist/utils/git.test.js.map +1 -1
- package/dist/utils/multi-git.d.ts +40 -0
- package/dist/utils/multi-git.d.ts.map +1 -1
- package/dist/utils/multi-git.js +80 -0
- package/dist/utils/multi-git.js.map +1 -1
- package/dist/utils/multi-git.test.js +54 -1
- package/dist/utils/multi-git.test.js.map +1 -1
- package/dist/utils/open-editor.d.ts +20 -0
- package/dist/utils/open-editor.d.ts.map +1 -0
- package/dist/utils/open-editor.js +44 -0
- package/dist/utils/open-editor.js.map +1 -0
- package/dist/utils/pr.d.ts +50 -0
- package/dist/utils/pr.d.ts.map +1 -0
- package/dist/utils/pr.js +144 -0
- package/dist/utils/pr.js.map +1 -0
- package/dist/utils/pr.test.d.ts +2 -0
- package/dist/utils/pr.test.d.ts.map +1 -0
- package/dist/utils/pr.test.js +47 -0
- package/dist/utils/pr.test.js.map +1 -0
- package/dist/utils/resolve-workspace.d.ts +30 -0
- package/dist/utils/resolve-workspace.d.ts.map +1 -0
- package/dist/utils/resolve-workspace.js +77 -0
- package/dist/utils/resolve-workspace.js.map +1 -0
- package/package.json +11 -11
package/dist/mcp/server.js
CHANGED
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
2
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
3
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
-
import { execa } from 'execa';
|
|
5
|
-
import * as fs from 'node:fs/promises';
|
|
6
4
|
import * as path from 'node:path';
|
|
7
5
|
import { loadConfig } from '../core/config.js';
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
import { enabledTools, findTool } from './tools.js';
|
|
7
|
+
/**
|
|
8
|
+
* Resolves the workspace path for a tool call.
|
|
9
|
+
*
|
|
10
|
+
* Precedence: an explicit `startMcpServer` argument, then `args.workspaceId`
|
|
11
|
+
* under `config.workspacesDir`, then the current working directory. A
|
|
12
|
+
* `workspaceId` that resolves outside `workspacesDir` (via `..` or an absolute
|
|
13
|
+
* path) is rejected — the HTTP server has this guard; the MCP server did not.
|
|
14
|
+
*/
|
|
15
|
+
function resolveWorkspacePath(explicit, config, args) {
|
|
16
|
+
if (explicit)
|
|
17
|
+
return explicit;
|
|
18
|
+
if (args && typeof args.workspaceId === 'string' && args.workspaceId.length > 0) {
|
|
19
|
+
const base = path.resolve(config.workspacesDir);
|
|
20
|
+
const resolved = path.resolve(base, args.workspaceId);
|
|
21
|
+
const rel = path.relative(base, resolved);
|
|
22
|
+
if (rel === '' || rel.startsWith('..') || path.isAbsolute(rel)) {
|
|
23
|
+
throw new Error(`Invalid workspaceId "${args.workspaceId}": resolves outside the workspaces directory.`);
|
|
24
|
+
}
|
|
25
|
+
return resolved;
|
|
26
|
+
}
|
|
27
|
+
return process.cwd();
|
|
28
|
+
}
|
|
11
29
|
export async function startMcpServer(workspacePath) {
|
|
12
30
|
const server = new Server({
|
|
13
31
|
name: 'nexusflow-mcp',
|
|
14
|
-
version: '0.
|
|
32
|
+
version: '0.2.0',
|
|
15
33
|
}, {
|
|
16
34
|
capabilities: {
|
|
17
35
|
tools: {},
|
|
@@ -19,289 +37,40 @@ export async function startMcpServer(workspacePath) {
|
|
|
19
37
|
});
|
|
20
38
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
21
39
|
const config = await loadConfig();
|
|
22
|
-
|
|
23
|
-
{
|
|
24
|
-
name:
|
|
25
|
-
description:
|
|
26
|
-
inputSchema:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
type: 'string',
|
|
31
|
-
description: 'The search query or regular expression',
|
|
32
|
-
},
|
|
33
|
-
workspaceId: {
|
|
34
|
-
type: 'string',
|
|
35
|
-
description: 'Optional ID/branchName of the workspace to search. If omitted, uses the currently active workspace.',
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
required: ['query'],
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
name: 'sync_workspace',
|
|
43
|
-
description: 'Rebase every repository in the NexusFlow workspace onto its base branch. Safe to call non-interactively: dirty working trees are auto-stashed and restored, so a dirty tree is never mis-reported as a conflict. Returns structured per-repo results (status: up-to-date | rebased | conflict | stash-conflict | error) and records them to the workspace state file.',
|
|
44
|
-
inputSchema: {
|
|
45
|
-
type: 'object',
|
|
46
|
-
properties: {
|
|
47
|
-
workspaceId: {
|
|
48
|
-
type: 'string',
|
|
49
|
-
description: 'Optional ID/branchName of the workspace to sync. If omitted, uses the currently active workspace.',
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
name: 'get_service_logs',
|
|
56
|
-
description: 'Get the recent logs for a specific running service in the workspace to debug runtime issues.',
|
|
57
|
-
inputSchema: {
|
|
58
|
-
type: 'object',
|
|
59
|
-
properties: {
|
|
60
|
-
serviceName: {
|
|
61
|
-
type: 'string',
|
|
62
|
-
description: 'The name of the service to fetch logs for (e.g. "frontend", "backend-api")',
|
|
63
|
-
},
|
|
64
|
-
lines: {
|
|
65
|
-
type: 'number',
|
|
66
|
-
description: 'Number of lines to fetch. Default 50.',
|
|
67
|
-
},
|
|
68
|
-
workspaceId: {
|
|
69
|
-
type: 'string',
|
|
70
|
-
description: 'Optional ID/branchName of the workspace. If omitted, uses the currently active workspace.',
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
required: ['serviceName'],
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
];
|
|
77
|
-
if (config.localLlm?.enabled) {
|
|
78
|
-
tools.push({
|
|
79
|
-
name: 'delegate_to_local_agent',
|
|
80
|
-
description: 'Delegate simple, high-volume, or repetitive tasks (like searching code, parsing raw service logs, or generating boilerplate) to the local Small Language Model (SLM) running on the user\'s machine to save remote tokens.',
|
|
81
|
-
inputSchema: {
|
|
82
|
-
type: 'object',
|
|
83
|
-
properties: {
|
|
84
|
-
instruction: {
|
|
85
|
-
type: 'string',
|
|
86
|
-
description: 'The specific instruction for the local agent (e.g., "Scan the last 50 lines of logs and explain the database error").',
|
|
87
|
-
},
|
|
88
|
-
filesToRead: {
|
|
89
|
-
type: 'array',
|
|
90
|
-
items: { type: 'string' },
|
|
91
|
-
description: 'Optional list of workspace-relative file paths or log files that the local agent should read and use as context.',
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
required: ['instruction'],
|
|
95
|
-
},
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
return { tools };
|
|
40
|
+
return {
|
|
41
|
+
tools: enabledTools(config).map((t) => ({
|
|
42
|
+
name: t.name,
|
|
43
|
+
description: t.description,
|
|
44
|
+
inputSchema: t.inputSchema,
|
|
45
|
+
...(t.annotations ? { annotations: t.annotations } : {}),
|
|
46
|
+
})),
|
|
47
|
+
};
|
|
99
48
|
});
|
|
49
|
+
// Return type is annotated `any` because the SDK's ServerResult union now
|
|
50
|
+
// includes a task-augmented variant; a plain `{ content, isError }` result is
|
|
51
|
+
// valid but does not narrow cleanly against it.
|
|
100
52
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
101
53
|
const { name, arguments: args } = request.params;
|
|
102
54
|
const config = await loadConfig();
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
// Fallback to CWD
|
|
111
|
-
resolvedWorkspacePath = process.cwd();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
if (name === 'delegate_to_local_agent') {
|
|
115
|
-
const instruction = args.instruction;
|
|
116
|
-
const filesToRead = args.filesToRead || [];
|
|
117
|
-
try {
|
|
118
|
-
if (!config.localLlm || !config.localLlm.enabled) {
|
|
119
|
-
throw new Error('Local AI agent delegation is disabled. Enable it in ~/.nexusflow/config.json or settings.');
|
|
120
|
-
}
|
|
121
|
-
const contextFiles = [];
|
|
122
|
-
const normalizedWorkspace = resolvedWorkspacePath.endsWith(path.sep)
|
|
123
|
-
? resolvedWorkspacePath
|
|
124
|
-
: resolvedWorkspacePath + path.sep;
|
|
125
|
-
for (const relativePath of filesToRead) {
|
|
126
|
-
const filePath = path.resolve(resolvedWorkspacePath, relativePath);
|
|
127
|
-
if (!filePath.startsWith(normalizedWorkspace)) {
|
|
128
|
-
contextFiles.push({
|
|
129
|
-
path: relativePath,
|
|
130
|
-
content: '[Access denied: path is outside workspace boundary]',
|
|
131
|
-
});
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
try {
|
|
135
|
-
const content = await fs.readFile(filePath, 'utf-8');
|
|
136
|
-
// Truncate file content if it's too large to prevent overloading local SLM
|
|
137
|
-
const truncatedContent = content.length > 50000
|
|
138
|
-
? content.substring(0, 50000) + '\n\n[Content truncated by NexusFlow to save local context size...]'
|
|
139
|
-
: content;
|
|
140
|
-
contextFiles.push({
|
|
141
|
-
path: relativePath,
|
|
142
|
-
content: truncatedContent,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
catch (e) {
|
|
146
|
-
contextFiles.push({
|
|
147
|
-
path: relativePath,
|
|
148
|
-
content: `[Error reading file: ${e.message || 'unknown error'}]`,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
// Build messages
|
|
153
|
-
const messages = [];
|
|
154
|
-
let systemPrompt = 'You are the NexusFlow local assistant. You are running locally on the user\'s machine to help the remote supervisor agent solve a specific sub-task in a multi-repo workspace.\n';
|
|
155
|
-
systemPrompt += 'Your goal is to be extremely precise, concise, and return only the distilled findings/code to save remote network tokens. Keep your response short, focused, and directly address the instruction.';
|
|
156
|
-
messages.push({ role: 'system', content: systemPrompt });
|
|
157
|
-
let userPrompt = '';
|
|
158
|
-
if (contextFiles.length > 0) {
|
|
159
|
-
userPrompt += 'Here is the local file/log context:\n\n';
|
|
160
|
-
for (const file of contextFiles) {
|
|
161
|
-
userPrompt += `--- FILE: ${file.path} ---\n${file.content}\n\n`;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
userPrompt += `Instruction: ${instruction}`;
|
|
165
|
-
messages.push({ role: 'user', content: userPrompt });
|
|
166
|
-
const result = await callLocalLlm(config.localLlm, messages);
|
|
167
|
-
return {
|
|
168
|
-
content: [
|
|
169
|
-
{
|
|
170
|
-
type: 'text',
|
|
171
|
-
text: result,
|
|
172
|
-
},
|
|
173
|
-
],
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
catch (error) {
|
|
177
|
-
return {
|
|
178
|
-
content: [
|
|
179
|
-
{
|
|
180
|
-
type: 'text',
|
|
181
|
-
text: `Error delegating to local agent: ${error.message}`,
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
isError: true,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
if (name === 'search_workspace') {
|
|
189
|
-
const query = args.query;
|
|
190
|
-
try {
|
|
191
|
-
const feature = await loadFeatureConfig(resolvedWorkspacePath);
|
|
192
|
-
if (!feature) {
|
|
193
|
-
throw new Error(`Workspace not found at ${resolvedWorkspacePath}. Make sure you are in a NexusFlow workspace or provide a valid workspaceId.`);
|
|
194
|
-
}
|
|
195
|
-
let allResults = '';
|
|
196
|
-
for (const repoPath of feature.repos) {
|
|
197
|
-
const repoName = path.basename(repoPath);
|
|
198
|
-
const worktreePath = path.join(resolvedWorkspacePath, repoName);
|
|
199
|
-
try {
|
|
200
|
-
await fs.access(worktreePath);
|
|
201
|
-
const { stdout } = await execa('git', ['grep', '-n', '-I', query], { cwd: worktreePath, reject: false });
|
|
202
|
-
if (stdout) {
|
|
203
|
-
const lines = stdout.split('\n').map(line => `[${repoName}] ${line}`);
|
|
204
|
-
allResults += lines.join('\n') + '\n';
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
catch (e) {
|
|
208
|
-
// Ignore error or exitCode 1 (no match)
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
return {
|
|
212
|
-
content: [
|
|
213
|
-
{
|
|
214
|
-
type: 'text',
|
|
215
|
-
text: allResults || 'No results found across the workspace repositories.',
|
|
216
|
-
},
|
|
217
|
-
],
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
catch (error) {
|
|
221
|
-
return {
|
|
222
|
-
content: [
|
|
223
|
-
{
|
|
224
|
-
type: 'text',
|
|
225
|
-
text: `Error searching workspace: ${error.message}`,
|
|
226
|
-
},
|
|
227
|
-
],
|
|
228
|
-
isError: true,
|
|
229
|
-
};
|
|
230
|
-
}
|
|
55
|
+
const tool = findTool(name);
|
|
56
|
+
if (!tool || (tool.enabled && !tool.enabled(config))) {
|
|
57
|
+
return {
|
|
58
|
+
content: [{ type: 'text', text: `Tool not found: ${name}` }],
|
|
59
|
+
isError: true,
|
|
60
|
+
};
|
|
231
61
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (!feature) {
|
|
236
|
-
throw new Error(`Workspace not found at ${resolvedWorkspacePath}. Make sure you are in a NexusFlow workspace or provide a valid workspaceId.`);
|
|
237
|
-
}
|
|
238
|
-
const report = await syncWorkspace(resolvedWorkspacePath);
|
|
239
|
-
return {
|
|
240
|
-
content: [
|
|
241
|
-
{
|
|
242
|
-
type: 'text',
|
|
243
|
-
text: JSON.stringify(report, null, 2),
|
|
244
|
-
},
|
|
245
|
-
],
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
catch (error) {
|
|
249
|
-
return {
|
|
250
|
-
content: [
|
|
251
|
-
{
|
|
252
|
-
type: 'text',
|
|
253
|
-
text: `Error syncing workspace: ${error.message}`,
|
|
254
|
-
},
|
|
255
|
-
],
|
|
256
|
-
isError: true,
|
|
257
|
-
};
|
|
258
|
-
}
|
|
62
|
+
let resolvedWorkspacePath;
|
|
63
|
+
try {
|
|
64
|
+
resolvedWorkspacePath = resolveWorkspacePath(workspacePath, config, args);
|
|
259
65
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
try {
|
|
266
|
-
await fs.access(logFilePath);
|
|
267
|
-
}
|
|
268
|
-
catch {
|
|
269
|
-
return {
|
|
270
|
-
content: [
|
|
271
|
-
{
|
|
272
|
-
type: 'text',
|
|
273
|
-
text: `Log file for service "${serviceName}" not found. Ensure the service is running via "nexusflow start".`,
|
|
274
|
-
},
|
|
275
|
-
],
|
|
276
|
-
isError: true,
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
const content = await fs.readFile(logFilePath, 'utf8');
|
|
280
|
-
const logLines = content.split('\n');
|
|
281
|
-
const tail = logLines.slice(-lines).join('\n');
|
|
282
|
-
return {
|
|
283
|
-
content: [
|
|
284
|
-
{
|
|
285
|
-
type: 'text',
|
|
286
|
-
text: tail || '(empty log)',
|
|
287
|
-
},
|
|
288
|
-
],
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
catch (error) {
|
|
292
|
-
return {
|
|
293
|
-
content: [
|
|
294
|
-
{
|
|
295
|
-
type: 'text',
|
|
296
|
-
text: `Error reading logs: ${error.message}`,
|
|
297
|
-
},
|
|
298
|
-
],
|
|
299
|
-
isError: true,
|
|
300
|
-
};
|
|
301
|
-
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
return {
|
|
68
|
+
content: [{ type: 'text', text: error.message }],
|
|
69
|
+
isError: true,
|
|
70
|
+
};
|
|
302
71
|
}
|
|
303
|
-
|
|
304
|
-
|
|
72
|
+
const ctx = { config, workspacePath: resolvedWorkspacePath };
|
|
73
|
+
return tool.handler((args ?? {}), ctx);
|
|
305
74
|
});
|
|
306
75
|
const transport = new StdioServerTransport();
|
|
307
76
|
await server.connect(transport);
|
package/dist/mcp/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,QAAQ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ACJ,CAAC;QAED,MAAM,GAAG,GAAgB,EAAE,MAAM,EAAE,aAAa,EAAE,qBAAqB,EAAE,CAAC;QAC1E,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,IAAI,EAAE,CAA4B,EAAE,GAAG,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module mcp/tools
|
|
3
|
+
* Registry of MCP tools NexusFlow exposes to AI assistants. Each tool declares
|
|
4
|
+
* its schema, MCP annotations, an optional `enabled` predicate, and a handler.
|
|
5
|
+
* `server.ts` lists the enabled tools and dispatches calls to their handlers,
|
|
6
|
+
* so adding a tool means adding one entry here.
|
|
7
|
+
*/
|
|
8
|
+
import type { NexusFlowConfig } from '../types.js';
|
|
9
|
+
/** Context passed to every tool handler. `workspacePath` is already resolved and validated. */
|
|
10
|
+
export interface ToolContext {
|
|
11
|
+
config: NexusFlowConfig;
|
|
12
|
+
workspacePath: string;
|
|
13
|
+
}
|
|
14
|
+
/** MCP tool call result. */
|
|
15
|
+
export interface ToolResult {
|
|
16
|
+
content: {
|
|
17
|
+
type: 'text';
|
|
18
|
+
text: string;
|
|
19
|
+
}[];
|
|
20
|
+
isError?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** MCP tool annotations (hints only; clients may ignore them). */
|
|
23
|
+
export interface ToolAnnotations {
|
|
24
|
+
title?: string;
|
|
25
|
+
readOnlyHint?: boolean;
|
|
26
|
+
destructiveHint?: boolean;
|
|
27
|
+
idempotentHint?: boolean;
|
|
28
|
+
openWorldHint?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** A single registered MCP tool. */
|
|
31
|
+
export interface NexusFlowTool {
|
|
32
|
+
name: string;
|
|
33
|
+
description: string;
|
|
34
|
+
inputSchema: Record<string, unknown>;
|
|
35
|
+
annotations?: ToolAnnotations;
|
|
36
|
+
/** When present, the tool is only listed/callable if this returns true. */
|
|
37
|
+
enabled?: (config: NexusFlowConfig) => boolean;
|
|
38
|
+
handler: (args: Record<string, unknown>, ctx: ToolContext) => Promise<ToolResult>;
|
|
39
|
+
}
|
|
40
|
+
export declare const tools: NexusFlowTool[];
|
|
41
|
+
/** Returns the tools enabled for the given config. */
|
|
42
|
+
export declare function enabledTools(config: NexusFlowConfig): NexusFlowTool[];
|
|
43
|
+
/** Finds a tool by name (regardless of enabled state). */
|
|
44
|
+
export declare function findTool(name: string): NexusFlowTool | undefined;
|
|
45
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/mcp/tools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAkBnD,+FAA+F;AAC/F,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,eAAe,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,4BAA4B;AAC5B,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,kEAAkE;AAClE,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,oCAAoC;AACpC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CA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