mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-07 07:55:13 +02:00
* docs(specs): design research-agent MCP tools and ktx mcp daemon Adds the 2026-05-14 design spec for exposing four new MCP tools (discover_data, entity_details, dictionary_search, sql_execution), shipping a ktx-research skill, and introducing an HTTP-only ktx mcp daemon so external agents can use KTX as a research-capable context layer. * Refine research-agent MCP tools spec after adversarial review iteration 1 * Refine research-agent MCP tools spec after adversarial review iteration 2 * Refine research-agent MCP tools spec after adversarial review iteration 3 * Refine spec: drop connectionName compat carve-out and ground summary/snippet provenance per kind * feat(daemon): validate read-only SQL with sqlglot * feat(context): expose read-only SQL validation port * feat(context): register MCP sql execution tool * feat(context): execute MCP SQL through validated connector path * test(context): update SQL analysis port fixtures * docs: add research-agent MCP sql execution foundation plan * feat(context): add scan-backed entity details service * feat(context): register MCP entity details tool * feat(context): expose local MCP entity details * test(context): align entity details scan fixtures * docs: add research-agent MCP entity_details plan * feat(context): add dictionary search service * feat(context): register MCP dictionary search tool * feat(context): expose local MCP dictionary search * docs: add research-agent MCP dictionary_search plan * feat: add MCP discover data service * feat: expose discover data MCP tool * feat: wire local discover data MCP port * docs: add research-agent MCP discover_data plan * feat(cli): add mcp http security helpers * feat(cli): host mcp over streamable http * feat(cli): manage mcp daemon lifecycle * feat(cli): add ktx mcp commands * fix(cli): stabilize mcp daemon verification * docs: add research-agent MCP http daemon plan * feat(cli): install KTX research skill * feat(cli): configure MCP clients in setup agents * feat(cli): support Claude local MCP setup scope * docs: add research-agent MCP setup-agents plan * refactor(context): use connectionId in warehouse verification tools * docs(context): update ingest verification prompts for connectionId * docs: add research-agent MCP ingest contract convergence plan * chore: build runtime artifacts in conductor setup --------- Co-authored-by: Andrey Avtomonov <7889985+andreybavt@users.noreply.github.com>
100 lines
3.4 KiB
TypeScript
100 lines
3.4 KiB
TypeScript
import { createRequire } from 'node:module';
|
|
|
|
import type { KtxConnectionArgs } from './connection.js';
|
|
import type { KtxDoctorArgs } from './doctor.js';
|
|
import type { KtxKnowledgeArgs } from './knowledge.js';
|
|
import type { KtxPublicIngestArgs } from './public-ingest.js';
|
|
import type { KtxRuntimeArgs } from './runtime.js';
|
|
import type { KtxSetupArgs } from './setup.js';
|
|
import type { KtxSlArgs } from './sl.js';
|
|
import { profileMark, profileSpan } from './startup-profile.js';
|
|
import type { KtxTextIngestArgs } from './text-ingest.js';
|
|
|
|
profileMark('module:cli-runtime');
|
|
|
|
const requirePackageJson = createRequire(import.meta.url);
|
|
|
|
export interface KtxCliPackageInfo {
|
|
name: string;
|
|
version: string;
|
|
contextPackageName: '@ktx/context';
|
|
}
|
|
|
|
export interface KtxCliIo {
|
|
stdout: { isTTY?: boolean; columns?: number; write(chunk: string): void };
|
|
stderr: { write(chunk: string): void };
|
|
}
|
|
|
|
export interface KtxCliDeps {
|
|
setup?: (args: KtxSetupArgs, io: KtxCliIo) => Promise<number>;
|
|
connection?: (args: KtxConnectionArgs, io: KtxCliIo) => Promise<number>;
|
|
doctor?: (args: KtxDoctorArgs, io: KtxCliIo) => Promise<number>;
|
|
publicIngest?: (args: KtxPublicIngestArgs, io: KtxCliIo) => Promise<number>;
|
|
textIngest?: (args: KtxTextIngestArgs, io: KtxCliIo) => Promise<number>;
|
|
runtime?: (args: KtxRuntimeArgs, io: KtxCliIo) => Promise<number>;
|
|
knowledge?: (args: KtxKnowledgeArgs, io: KtxCliIo) => Promise<number>;
|
|
sl?: (args: KtxSlArgs, io: KtxCliIo) => Promise<number>;
|
|
mcp?: {
|
|
startDaemon?: typeof import('./managed-mcp-daemon.js').startKtxMcpDaemon;
|
|
stopDaemon?: typeof import('./managed-mcp-daemon.js').stopKtxMcpDaemon;
|
|
readStatus?: typeof import('./managed-mcp-daemon.js').readKtxMcpDaemonStatus;
|
|
runServer?: typeof import('./mcp-http-server.js').runKtxMcpHttpServer;
|
|
};
|
|
}
|
|
|
|
export function getKtxCliPackageInfo(): KtxCliPackageInfo {
|
|
return packageInfoFromJson(requirePackageJson('../package.json'));
|
|
}
|
|
|
|
export function packageInfoFromJson(packageJson: unknown): KtxCliPackageInfo {
|
|
if (
|
|
typeof packageJson !== 'object' ||
|
|
packageJson === null ||
|
|
!('name' in packageJson) ||
|
|
!('version' in packageJson) ||
|
|
typeof packageJson.name !== 'string' ||
|
|
typeof packageJson.version !== 'string'
|
|
) {
|
|
throw new Error('Invalid KTX CLI package metadata');
|
|
}
|
|
|
|
return {
|
|
name: packageJson.name,
|
|
version: packageJson.version,
|
|
contextPackageName: '@ktx/context',
|
|
};
|
|
}
|
|
|
|
async function runInit(args: { projectDir: string; force: boolean }, io: KtxCliIo): Promise<number> {
|
|
const { initKtxProject } = await import('@ktx/context/project');
|
|
const result = await initKtxProject({
|
|
projectDir: args.projectDir,
|
|
force: args.force,
|
|
});
|
|
|
|
io.stdout.write(`Initialized KTX project at ${result.projectDir}\n`);
|
|
io.stdout.write(`Config: ${result.configPath}\n`);
|
|
io.stdout.write(`Commit: ${result.commitHash ?? 'none'}\n`);
|
|
return 0;
|
|
}
|
|
|
|
export async function runInitForCommander(
|
|
args: { projectDir: string; force: boolean },
|
|
io: KtxCliIo,
|
|
): Promise<number> {
|
|
return await runInit(args, io);
|
|
}
|
|
|
|
export async function runKtxCli(
|
|
argv = process.argv.slice(2),
|
|
io: KtxCliIo = process,
|
|
deps: KtxCliDeps = {},
|
|
): Promise<number> {
|
|
const info = getKtxCliPackageInfo();
|
|
profileMark('runtime:runKtxCli');
|
|
const { runCommanderKtxCli } = await profileSpan('import ./cli-program.js', () => import('./cli-program.js'));
|
|
|
|
return await runCommanderKtxCli(argv, io, deps, info, {
|
|
runInit: runInitForCommander,
|
|
});
|
|
}
|