@suco/su-auggie-mcp 0.1.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/dist/index.js ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * suco-auggie-mcp CLI
4
+ * MCP server exposing Augment Code context engine capabilities
5
+ */
6
+ import { Command } from 'commander';
7
+ import { startServer } from './server.js';
8
+ import { createLogger } from './logger.js';
9
+ import { setDebugMode, setPersistenceEnabled } from './config.js';
10
+ const logger = createLogger('CLI');
11
+ /** Parse workspace paths from CLI argument (supports comma-separated) */
12
+ function parseWorkspacePaths(value, previous) {
13
+ const paths = value.split(',').map((p) => p.trim()).filter(Boolean);
14
+ return previous.concat(paths);
15
+ }
16
+ /** Main entry point */
17
+ async function main() {
18
+ const program = new Command();
19
+ program
20
+ .name('suco-auggie-mcp')
21
+ .description('MCP server exposing Augment Code context engine capabilities')
22
+ .version('0.1.0')
23
+ .option('-w, --workspace <path>', 'Add workspace path (can be repeated or comma-separated)', parseWorkspacePaths, [])
24
+ .option('--ignore-roots', 'Ignore MCP roots and CWD fallback, use only -w workspaces')
25
+ .option('--debug', 'Enable debug mode (logging capability + debug tool)')
26
+ .option('-n, --no-persistent', 'Disable index persistence (in-memory only, re-indexes on restart)')
27
+ .parse();
28
+ const options = program.opts();
29
+ // Set debug mode before anything else
30
+ if (options.debug) {
31
+ setDebugMode(true);
32
+ logger.info('Debug mode enabled');
33
+ }
34
+ // Set persistence mode (--no-persistent sets persistent to false)
35
+ if (options.persistent === false) {
36
+ setPersistenceEnabled(false);
37
+ logger.info('Persistence disabled (in-memory only)');
38
+ }
39
+ // Pass CLI options to server - workspace resolution happens after MCP connect
40
+ const cliOptions = {
41
+ workspaces: options.workspace,
42
+ ignoreRoots: options.ignoreRoots ?? false,
43
+ };
44
+ if (cliOptions.workspaces.length > 0) {
45
+ logger.info(`CLI workspaces: ${cliOptions.workspaces.join(', ')}`);
46
+ }
47
+ // Start MCP server (workspace resolution happens after connect)
48
+ await startServer(cliOptions);
49
+ }
50
+ main().catch((err) => {
51
+ logger.error('Fatal error', err);
52
+ process.exit(1);
53
+ });
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Debug logger for suco-auggie-mcp
3
+ */
4
+ /** Logger interface */
5
+ export interface Logger {
6
+ debug(message: string, ...args: unknown[]): void;
7
+ info(message: string, ...args: unknown[]): void;
8
+ warn(message: string, ...args: unknown[]): void;
9
+ error(message: string, ...args: unknown[]): void;
10
+ }
11
+ /** Create a logger with optional prefix */
12
+ export declare function createLogger(prefix?: string): Logger;
13
+ /** Default logger instance */
14
+ export declare const logger: Logger;
package/dist/logger.js ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Debug logger for suco-auggie-mcp
3
+ */
4
+ import { isDebugMode } from './config.js';
5
+ /** Create a logger with optional prefix */
6
+ export function createLogger(prefix) {
7
+ const formatMessage = (level, message) => {
8
+ const timestamp = new Date().toISOString();
9
+ const prefixStr = prefix ? `[${prefix}] ` : '';
10
+ return `${timestamp} ${level} ${prefixStr}${message}`;
11
+ };
12
+ return {
13
+ debug(message, ...args) {
14
+ if (isDebugMode()) {
15
+ console.error(formatMessage('DEBUG', message), ...args);
16
+ }
17
+ },
18
+ info(message, ...args) {
19
+ if (isDebugMode()) {
20
+ console.error(formatMessage('INFO', message), ...args);
21
+ }
22
+ },
23
+ warn(message, ...args) {
24
+ console.error(formatMessage('WARN', message), ...args);
25
+ },
26
+ error(message, ...args) {
27
+ console.error(formatMessage('ERROR', message), ...args);
28
+ },
29
+ };
30
+ }
31
+ /** Default logger instance */
32
+ export const logger = createLogger();
@@ -0,0 +1,62 @@
1
+ /**
2
+ * MCP notification utilities - send logging messages and notifications to connected client
3
+ */
4
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
+ /** Log levels supported by MCP */
6
+ export type McpLogLevel = 'debug' | 'info' | 'notice' | 'warning' | 'error' | 'critical' | 'alert' | 'emergency';
7
+ /** Set the MCP server reference (called during startup) */
8
+ export declare function setMcpServer(server: McpServer): void;
9
+ /** Get the MCP server reference */
10
+ export declare function getMcpServer(): McpServer | null;
11
+ /**
12
+ * Send a logging message to the connected MCP client.
13
+ * Safe to call even if server is not connected - will silently fail.
14
+ */
15
+ export declare function sendLogToClient(level: McpLogLevel, message: string, data?: unknown): Promise<void>;
16
+ /**
17
+ * Check if client supports elicitation
18
+ */
19
+ export declare function clientSupportsElicitation(): boolean;
20
+ /** Elicitation schema property types */
21
+ type ElicitPropertyType = {
22
+ type: 'string';
23
+ description?: string;
24
+ title?: string;
25
+ default?: string;
26
+ } | {
27
+ type: 'string';
28
+ enum: string[];
29
+ description?: string;
30
+ title?: string;
31
+ enumNames?: string[];
32
+ default?: string;
33
+ } | {
34
+ type: 'boolean';
35
+ description?: string;
36
+ title?: string;
37
+ default?: boolean;
38
+ } | {
39
+ type: 'number' | 'integer';
40
+ description?: string;
41
+ title?: string;
42
+ minimum?: number;
43
+ maximum?: number;
44
+ default?: number;
45
+ };
46
+ /** Elicitation request parameters */
47
+ export interface ElicitParams {
48
+ message: string;
49
+ requestedSchema: {
50
+ type: 'object';
51
+ properties: Record<string, ElicitPropertyType>;
52
+ required?: string[];
53
+ };
54
+ }
55
+ /**
56
+ * Elicit input from user (only if client supports it)
57
+ */
58
+ export declare function elicitInput(params: ElicitParams): Promise<{
59
+ action: 'accept' | 'decline' | 'cancel';
60
+ content?: Record<string, unknown>;
61
+ } | null>;
62
+ export {};
@@ -0,0 +1,54 @@
1
+ /**
2
+ * MCP notification utilities - send logging messages and notifications to connected client
3
+ */
4
+ /** Singleton reference to the MCP server */
5
+ let mcpServer = null;
6
+ /** Set the MCP server reference (called during startup) */
7
+ export function setMcpServer(server) {
8
+ mcpServer = server;
9
+ }
10
+ /** Get the MCP server reference */
11
+ export function getMcpServer() {
12
+ return mcpServer;
13
+ }
14
+ /**
15
+ * Send a logging message to the connected MCP client.
16
+ * Safe to call even if server is not connected - will silently fail.
17
+ */
18
+ export async function sendLogToClient(level, message, data) {
19
+ if (!mcpServer)
20
+ return;
21
+ try {
22
+ await mcpServer.server.sendLoggingMessage({
23
+ level,
24
+ logger: 'suco-auggie',
25
+ data: data !== undefined ? { message, ...data } : message,
26
+ });
27
+ }
28
+ catch {
29
+ // Silently ignore - client might not support logging or be disconnected
30
+ }
31
+ }
32
+ /**
33
+ * Check if client supports elicitation
34
+ */
35
+ export function clientSupportsElicitation() {
36
+ if (!mcpServer)
37
+ return false;
38
+ const caps = mcpServer.server.getClientCapabilities();
39
+ return caps?.elicitation !== undefined;
40
+ }
41
+ /**
42
+ * Elicit input from user (only if client supports it)
43
+ */
44
+ export async function elicitInput(params) {
45
+ if (!mcpServer || !clientSupportsElicitation())
46
+ return null;
47
+ try {
48
+ const result = await mcpServer.server.elicitInput(params);
49
+ return result;
50
+ }
51
+ catch {
52
+ return null;
53
+ }
54
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * MCP Server setup with stdio transport
3
+ */
4
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
+ import type { CLIOptions } from './index.js';
6
+ /** Create and configure the MCP server */
7
+ export declare function createServer(): McpServer;
8
+ /** Start the MCP server with stdio transport */
9
+ export declare function startServer(options: CLIOptions): Promise<void>;
package/dist/server.js ADDED
@@ -0,0 +1,226 @@
1
+ /**
2
+ * MCP Server setup with stdio transport
3
+ */
4
+ import { fileURLToPath } from 'node:url';
5
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
7
+ import { createLogger } from './logger.js';
8
+ import { isDebugMode } from './config.js';
9
+ import { workspaceManager } from './workspace-manager.js';
10
+ import { hasCredentials, startSessionWatcher, stopSessionWatcher, onAuthChange, } from './auth.js';
11
+ import { setMcpServer, clientSupportsElicitation, elicitInput, sendLogToClient, } from './mcp-notifications.js';
12
+ import { CODEBASE_TOOL_NAME, CODEBASE_TOOL_DESCRIPTION, CODEBASE_PARAMS_SHAPE, handleCodebaseTool, } from './tools/codebase.js';
13
+ import { INDEX_TOOL_NAME, INDEX_TOOL_DESCRIPTION, INDEX_PARAMS_SHAPE, handleIndexTool, } from './tools/index-tool.js';
14
+ import { DEBUG_TOOL_NAME, DEBUG_TOOL_DESCRIPTION, DEBUG_PARAMS_SHAPE, handleDebugTool, } from './tools/debug.js';
15
+ const logger = createLogger('Server');
16
+ /** Create and configure the MCP server */
17
+ export function createServer() {
18
+ const server = new McpServer({
19
+ name: 'suco-auggie-mcp',
20
+ version: '0.1.0',
21
+ });
22
+ // Register codebase tool
23
+ server.tool(CODEBASE_TOOL_NAME, CODEBASE_TOOL_DESCRIPTION, CODEBASE_PARAMS_SHAPE, async (args) => {
24
+ try {
25
+ const result = await handleCodebaseTool(args);
26
+ return { content: [{ type: 'text', text: result }] };
27
+ }
28
+ catch (err) {
29
+ const message = err instanceof Error ? err.message : String(err);
30
+ logger.error(`Codebase tool error: ${message}`);
31
+ return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };
32
+ }
33
+ });
34
+ // Register index tool
35
+ server.tool(INDEX_TOOL_NAME, INDEX_TOOL_DESCRIPTION, INDEX_PARAMS_SHAPE, async (args) => {
36
+ try {
37
+ const result = await handleIndexTool(args);
38
+ return { content: [{ type: 'text', text: result }] };
39
+ }
40
+ catch (err) {
41
+ const message = err instanceof Error ? err.message : String(err);
42
+ logger.error(`Index tool error: ${message}`);
43
+ return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };
44
+ }
45
+ });
46
+ // Register debug tool (only in debug mode)
47
+ if (isDebugMode()) {
48
+ logger.info('Registering debug tool (debug mode enabled)');
49
+ server.tool(DEBUG_TOOL_NAME, DEBUG_TOOL_DESCRIPTION, DEBUG_PARAMS_SHAPE, async (args) => {
50
+ try {
51
+ const result = await handleDebugTool(args);
52
+ return { content: [{ type: 'text', text: result }] };
53
+ }
54
+ catch (err) {
55
+ const message = err instanceof Error ? err.message : String(err);
56
+ logger.error(`Debug tool error: ${message}`);
57
+ return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };
58
+ }
59
+ });
60
+ }
61
+ return server;
62
+ }
63
+ /** Try to get credentials via elicitation if client supports it */
64
+ async function tryElicitCredentials() {
65
+ if (!clientSupportsElicitation()) {
66
+ logger.debug('Client does not support elicitation');
67
+ return false;
68
+ }
69
+ logger.info('Requesting API token via elicitation...');
70
+ sendLogToClient('info', 'Augment API token required. Please provide your credentials.');
71
+ const result = await elicitInput({
72
+ message: 'Augment API token is required for codebase indexing and search.\n\n' +
73
+ 'You can get a token from the Augment dashboard or use an existing one from ~/.auggie/session.json',
74
+ requestedSchema: {
75
+ type: 'object',
76
+ properties: {
77
+ apiToken: {
78
+ type: 'string',
79
+ title: 'API Token',
80
+ description: 'Your Augment API token',
81
+ },
82
+ },
83
+ required: ['apiToken'],
84
+ },
85
+ });
86
+ if (result?.action === 'accept' && result.content?.apiToken) {
87
+ const token = result.content.apiToken;
88
+ process.env.AUGMENT_API_TOKEN = token;
89
+ logger.info('API token received via elicitation');
90
+ sendLogToClient('info', 'API token configured successfully');
91
+ return true;
92
+ }
93
+ logger.warn('Elicitation cancelled or declined');
94
+ return false;
95
+ }
96
+ /**
97
+ * Check if client supports MCP roots capability
98
+ */
99
+ function clientSupportsRoots(server) {
100
+ const caps = server.server.getClientCapabilities();
101
+ return caps?.roots !== undefined;
102
+ }
103
+ /**
104
+ * Get roots from MCP client (returns empty array if not supported or fails)
105
+ */
106
+ async function getMcpRoots(server) {
107
+ if (!clientSupportsRoots(server)) {
108
+ logger.debug('Client does not support roots capability');
109
+ return [];
110
+ }
111
+ try {
112
+ const result = await server.server.listRoots();
113
+ const roots = [];
114
+ for (const root of result.roots) {
115
+ // Root URI is file:// URL, convert to path
116
+ if (root.uri.startsWith('file://')) {
117
+ const filePath = fileURLToPath(root.uri);
118
+ roots.push(filePath);
119
+ logger.debug(`MCP root: ${root.name ?? root.uri} -> ${filePath}`);
120
+ }
121
+ else {
122
+ logger.warn(`Ignoring non-file root: ${root.uri}`);
123
+ }
124
+ }
125
+ return roots;
126
+ }
127
+ catch (err) {
128
+ const message = err instanceof Error ? err.message : String(err);
129
+ logger.warn(`Failed to get MCP roots: ${message}`);
130
+ return [];
131
+ }
132
+ }
133
+ /**
134
+ * Resolve workspaces in priority order:
135
+ * 1. CLI -w workspaces (always added if provided)
136
+ * 2. MCP roots OR CWD fallback (if not --ignore-roots)
137
+ *
138
+ * Result: -w + (roots OR cwd)
139
+ * With --ignore-roots: only -w
140
+ */
141
+ async function resolveWorkspaces(server, options) {
142
+ // 1. Add CLI workspaces first (always)
143
+ if (options.workspaces.length > 0) {
144
+ logger.info(`Adding ${options.workspaces.length} workspace(s) from CLI`);
145
+ await workspaceManager.addWorkspaces(options.workspaces);
146
+ }
147
+ // If --ignore-roots, skip MCP roots and CWD fallback
148
+ if (options.ignoreRoots) {
149
+ if (!workspaceManager.hasWorkspaces()) {
150
+ throw new Error('No workspaces configured. Use -w to specify workspace paths when using --ignore-roots.');
151
+ }
152
+ return;
153
+ }
154
+ // 2. Try MCP roots, fallback to CWD if empty
155
+ const mcpRoots = await getMcpRoots(server);
156
+ if (mcpRoots.length > 0) {
157
+ logger.info(`Adding ${mcpRoots.length} workspace(s) from MCP roots`);
158
+ await workspaceManager.addWorkspaces(mcpRoots);
159
+ }
160
+ else {
161
+ // CWD is fallback for roots (regardless of -w)
162
+ logger.info('No MCP roots available, using current directory as fallback');
163
+ await workspaceManager.addWorkspace(process.cwd());
164
+ }
165
+ if (!workspaceManager.hasWorkspaces()) {
166
+ throw new Error('No workspaces configured. Use -w to specify workspace paths.');
167
+ }
168
+ }
169
+ /** Start the MCP server with stdio transport */
170
+ export async function startServer(options) {
171
+ const server = createServer();
172
+ const transport = new StdioServerTransport();
173
+ // Make server available for notifications
174
+ setMcpServer(server);
175
+ // Register auth change callback to reinitialize errored workspaces
176
+ onAuthChange(async (hasAuth) => {
177
+ if (hasAuth) {
178
+ logger.info('Auth credentials detected, reinitializing errored workspaces');
179
+ await workspaceManager.reinitializeErrored();
180
+ }
181
+ else {
182
+ logger.warn('Auth credentials removed - operations may fail');
183
+ sendLogToClient('warning', 'Augment credentials removed. Run `auggie login` to re-authenticate.');
184
+ }
185
+ });
186
+ // Start watching session file for auth changes
187
+ startSessionWatcher();
188
+ /** Graceful shutdown per MCP protocol */
189
+ async function shutdown() {
190
+ logger.info('Shutting down...');
191
+ // Stop session watcher
192
+ stopSessionWatcher();
193
+ // Close workspaces (saves state, stops watchers)
194
+ await workspaceManager.close();
195
+ // Close MCP server/transport per protocol
196
+ await server.close();
197
+ process.exit(0);
198
+ }
199
+ // Handle shutdown signals
200
+ process.on('SIGINT', shutdown);
201
+ process.on('SIGTERM', shutdown);
202
+ logger.info('Starting MCP server...');
203
+ await server.connect(transport);
204
+ logger.info('MCP server connected');
205
+ // Resolve workspaces AFTER connect (MCP roots require connection)
206
+ try {
207
+ await resolveWorkspaces(server, options);
208
+ logger.info(`Configured ${workspaceManager.count} workspace(s)`);
209
+ sendLogToClient('info', `Indexing ${workspaceManager.count} workspace(s)...`);
210
+ }
211
+ catch (err) {
212
+ const message = err instanceof Error ? err.message : String(err);
213
+ logger.error(`Workspace resolution failed: ${message}`);
214
+ sendLogToClient('error', message);
215
+ // Don't exit - allow user to provide workspaces via other means
216
+ }
217
+ // After workspace resolution, check credentials and try elicitation if needed
218
+ if (!hasCredentials()) {
219
+ logger.warn('No Augment API token found in environment');
220
+ sendLogToClient('warning', 'No Augment API token found. Indexing will fail without credentials.');
221
+ const gotCredentials = await tryElicitCredentials();
222
+ if (!gotCredentials) {
223
+ sendLogToClient('error', 'No API token provided. Set AUGMENT_API_TOKEN environment variable or provide via elicitation.');
224
+ }
225
+ }
226
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Codebase tool - semantic search and Q&A over indexed code
3
+ */
4
+ import { z } from 'zod';
5
+ /** Tool name */
6
+ export declare const CODEBASE_TOOL_NAME = "codebase";
7
+ /** Tool description */
8
+ export declare const CODEBASE_TOOL_DESCRIPTION = "Semantic search and Q&A over indexed code.\n\nModes:\n- search: Find relevant code snippets using natural language\n- ask: Search and get an LLM-generated answer about the code\n\nParameters:\n- mode: \"search\" or \"ask\" (required)\n- query: Natural language search query (required)\n- prompt: Additional prompt for ask mode (optional, defaults to query)\n- root: Workspace root path to search (optional, defaults to first workspace)";
9
+ /** Input schema for zod validation */
10
+ export declare const codebaseInputSchema: z.ZodObject<{
11
+ mode: z.ZodEnum<["search", "ask"]>;
12
+ query: z.ZodString;
13
+ prompt: z.ZodOptional<z.ZodString>;
14
+ root: z.ZodOptional<z.ZodString>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ mode: "search" | "ask";
17
+ query: string;
18
+ prompt?: string | undefined;
19
+ root?: string | undefined;
20
+ }, {
21
+ mode: "search" | "ask";
22
+ query: string;
23
+ prompt?: string | undefined;
24
+ root?: string | undefined;
25
+ }>;
26
+ /** Zod schema shape for MCP tool registration */
27
+ export declare const CODEBASE_PARAMS_SHAPE: {
28
+ mode: z.ZodEnum<["search", "ask"]>;
29
+ query: z.ZodString;
30
+ prompt: z.ZodOptional<z.ZodString>;
31
+ root: z.ZodOptional<z.ZodString>;
32
+ };
33
+ /** Handle codebase tool call */
34
+ export declare function handleCodebaseTool(input: unknown): Promise<string>;
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Codebase tool - semantic search and Q&A over indexed code
3
+ */
4
+ import { z } from 'zod';
5
+ import { workspaceManager } from '../workspace-manager.js';
6
+ import { createLogger } from '../logger.js';
7
+ const logger = createLogger('CodebaseTool');
8
+ /** Tool name */
9
+ export const CODEBASE_TOOL_NAME = 'codebase';
10
+ /** Tool description */
11
+ export const CODEBASE_TOOL_DESCRIPTION = `Semantic search and Q&A over indexed code.
12
+
13
+ Modes:
14
+ - search: Find relevant code snippets using natural language
15
+ - ask: Search and get an LLM-generated answer about the code
16
+
17
+ Parameters:
18
+ - mode: "search" or "ask" (required)
19
+ - query: Natural language search query (required)
20
+ - prompt: Additional prompt for ask mode (optional, defaults to query)
21
+ - root: Workspace root path to search (optional, defaults to first workspace)`;
22
+ /** Input schema for zod validation */
23
+ export const codebaseInputSchema = z.object({
24
+ mode: z.enum(['search', 'ask']),
25
+ query: z.string().min(1),
26
+ prompt: z.string().optional(),
27
+ root: z.string().optional(),
28
+ });
29
+ /** Zod schema shape for MCP tool registration */
30
+ export const CODEBASE_PARAMS_SHAPE = {
31
+ mode: z.enum(['search', 'ask']).describe('Operation mode: search for code or ask a question'),
32
+ query: z.string().min(1).describe('Natural language search query'),
33
+ prompt: z.string().optional().describe('Additional prompt for ask mode (optional)'),
34
+ root: z.string().optional().describe('Workspace root path (optional, defaults to first workspace)'),
35
+ };
36
+ /** Handle codebase tool call */
37
+ export async function handleCodebaseTool(input) {
38
+ // Validate input
39
+ const parsed = codebaseInputSchema.safeParse(input);
40
+ if (!parsed.success) {
41
+ throw new Error(`Invalid input: ${parsed.error.message}`);
42
+ }
43
+ const { mode, query, prompt, root } = parsed.data;
44
+ // Get workspace
45
+ const workspace = workspaceManager.resolveWorkspace(root);
46
+ const status = workspace.getStatus();
47
+ // Check if workspace is ready
48
+ if (status.status === 'error') {
49
+ throw new Error(`Workspace error: ${status.error}`);
50
+ }
51
+ if (status.indexed === 0) {
52
+ if (status.status === 'indexing') {
53
+ const progress = status.progress;
54
+ if (progress) {
55
+ const pct = progress.discovered > 0
56
+ ? Math.round((progress.indexed / progress.discovered) * 100)
57
+ : 0;
58
+ const discoveringNote = progress.discovering ? ' (still discovering)' : '';
59
+ return `Workspace is still indexing: ${progress.indexed}/${progress.discovered} files (${pct}%)${discoveringNote}. Please wait and try again.`;
60
+ }
61
+ return 'Workspace is still indexing. Please wait and try again.';
62
+ }
63
+ return 'No files indexed yet. The workspace may still be initializing.';
64
+ }
65
+ logger.debug(`${mode} query: "${query}" in ${workspace.root}`);
66
+ let result;
67
+ if (mode === 'search') {
68
+ result = await workspace.search(query);
69
+ }
70
+ else {
71
+ result = await workspace.searchAndAsk(query, prompt);
72
+ }
73
+ // Add note if indexing is in progress
74
+ if (status.status === 'indexing' && status.progress) {
75
+ const pct = status.progress.discovered > 0
76
+ ? Math.round((status.progress.indexed / status.progress.discovered) * 100)
77
+ : 0;
78
+ const discoveringNote = status.progress.discovering ? ', still discovering' : '';
79
+ const note = `Note: Indexing in progress (${status.progress.indexed}/${status.progress.discovered} files, ${pct}%${discoveringNote}). Results may be incomplete.\n\n`;
80
+ result = note + result;
81
+ }
82
+ return result;
83
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Debug tool - inspect internal server state (only available with --debug)
3
+ */
4
+ import { z } from 'zod';
5
+ /** Tool name */
6
+ export declare const DEBUG_TOOL_NAME = "debug";
7
+ /** Tool description */
8
+ export declare const DEBUG_TOOL_DESCRIPTION = "Inspect internal server state for troubleshooting.\n\nActions:\n- state: Dump full internal state (contexts, watchers, queues)\n- stats: Index statistics (file counts, sizes, timings)\n- config: Show current configuration values\n- capabilities: Show client MCP capabilities (elicitation, logging, etc.)\n- emit: Test MCP client notifications (logging or elicitation)\n\nParameters:\n- action: Required action to perform\n- root: Workspace root path for workspace-specific info (optional)\n- type: For emit action: \"logging\" or \"elicitation\"\n- message: Message for emit action (optional)";
9
+ /** Input schema for zod validation */
10
+ export declare const debugInputSchema: z.ZodObject<{
11
+ action: z.ZodEnum<["state", "stats", "config", "capabilities", "emit"]>;
12
+ root: z.ZodOptional<z.ZodString>;
13
+ type: z.ZodOptional<z.ZodEnum<["logging", "elicitation"]>>;
14
+ message: z.ZodOptional<z.ZodString>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ action: "config" | "capabilities" | "state" | "stats" | "emit";
17
+ type?: "elicitation" | "logging" | undefined;
18
+ message?: string | undefined;
19
+ root?: string | undefined;
20
+ }, {
21
+ action: "config" | "capabilities" | "state" | "stats" | "emit";
22
+ type?: "elicitation" | "logging" | undefined;
23
+ message?: string | undefined;
24
+ root?: string | undefined;
25
+ }>;
26
+ /** Zod schema shape for MCP tool registration */
27
+ export declare const DEBUG_PARAMS_SHAPE: {
28
+ action: z.ZodEnum<["state", "stats", "config", "capabilities", "emit"]>;
29
+ root: z.ZodOptional<z.ZodString>;
30
+ type: z.ZodOptional<z.ZodEnum<["logging", "elicitation"]>>;
31
+ message: z.ZodOptional<z.ZodString>;
32
+ };
33
+ /** Handle debug tool call */
34
+ export declare function handleDebugTool(input: unknown): Promise<string>;