@musashishao/agent-kit 1.8.2 → 1.9.1
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/.agent/agents/ai-architect.md +39 -0
- package/.agent/agents/ai-asset-factory.md +700 -0
- package/.agent/agents/ai-audio-factory.md +503 -0
- package/.agent/agents/cloud-engineer.md +39 -0
- package/.agent/agents/game-developer.md +190 -89
- package/.agent/agents/marketing-specialist.md +41 -0
- package/.agent/agents/orchestrator.md +113 -3
- package/.agent/agents/penetration-tester.md +15 -1
- package/.agent/agents/project-planner.md +67 -0
- package/.agent/agents/unity-mobile-master.md +949 -0
- package/.agent/mcp/config/registry.json +65 -51
- package/.agent/mcp/servers/notebooklm/README.md +114 -0
- package/.agent/mcp/servers/notebooklm/package.json +35 -0
- package/.agent/mcp/servers/notebooklm/src/auth/chrome.ts +225 -0
- package/.agent/mcp/servers/notebooklm/src/auth/index.ts +1 -0
- package/.agent/mcp/servers/notebooklm/src/index.ts +516 -0
- package/.agent/mcp/servers/notebooklm/src/services/index.ts +3 -0
- package/.agent/mcp/servers/notebooklm/src/services/library.ts +217 -0
- package/.agent/mcp/servers/notebooklm/src/services/notebooklm.ts +380 -0
- package/.agent/mcp/servers/notebooklm/tsconfig.json +15 -0
- package/.agent/mcp-gateway/README.md +169 -20
- package/.agent/mcp-gateway/package.json +22 -7
- package/.agent/mcp-gateway/src/auth/index.ts +55 -0
- package/.agent/mcp-gateway/src/auth/middleware.ts +242 -0
- package/.agent/mcp-gateway/src/auth/oauth.ts +462 -0
- package/.agent/mcp-gateway/src/auth/scopes.ts +227 -0
- package/.agent/mcp-gateway/src/index.ts +252 -105
- package/.agent/mcp-gateway/src/observability/index.ts +5 -0
- package/.agent/mcp-gateway/src/observability/otel.ts +405 -0
- package/.agent/mcp-gateway/src/transports/index.ts +5 -0
- package/.agent/mcp-gateway/src/transports/streamableHttp.ts +235 -0
- package/.agent/rules/CODEX.md +115 -2
- package/.agent/rules/CODE_RULES.md +73 -0
- package/.agent/rules/GEMINI.md +26 -1
- package/.agent/rules/MEMORY_STATE.md +110 -0
- package/.agent/rules/REFERENCE.md +40 -58
- package/.agent/rules/REF_SKILLS.md +116 -0
- package/.agent/rules/REF_WORKFLOWS.md +81 -0
- package/.agent/scripts/ak_cli.py +106 -5
- package/.agent/scripts/memory_manager.py +48 -9
- package/.agent/skills/3d-web-experience/SKILL.md +386 -0
- package/.agent/skills/DEPENDENCIES.md +54 -0
- package/.agent/skills/ab-test-setup/SKILL.md +77 -0
- package/.agent/skills/active-directory-attacks/SKILL.md +59 -0
- package/.agent/skills/agent-evaluation/SKILL.md +430 -0
- package/.agent/skills/agent-memory-systems/SKILL.md +426 -0
- package/.agent/skills/agent-tool-builder/SKILL.md +139 -0
- package/.agent/skills/ai-agents-architect/SKILL.md +115 -0
- package/.agent/skills/ai-product/SKILL.md +86 -0
- package/.agent/skills/ai-wrapper-product/SKILL.md +90 -0
- package/.agent/skills/analytics-tracking/SKILL.md +88 -0
- package/.agent/skills/anti-hallucination/SKILL.md +295 -0
- package/.agent/skills/anti-hallucination/scripts/check_hallucination.py +299 -0
- package/.agent/skills/api-fuzzing-bug-bounty/SKILL.md +66 -0
- package/.agent/skills/app-store-optimization/SKILL.md +66 -0
- package/.agent/skills/autonomous-agent-patterns/SKILL.md +414 -0
- package/.agent/skills/aws-penetration-testing/SKILL.md +50 -0
- package/.agent/skills/aws-serverless/SKILL.md +327 -0
- package/.agent/skills/azure-functions/SKILL.md +340 -0
- package/.agent/skills/bifurcation-analysis/SKILL.md +56 -0
- package/.agent/skills/brainstorming/SKILL.md +80 -6
- package/.agent/skills/broken-authentication/SKILL.md +53 -0
- package/.agent/skills/browser-automation/SKILL.md +408 -0
- package/.agent/skills/browser-extension-builder/SKILL.md +422 -0
- package/.agent/skills/bullmq-specialist/SKILL.md +424 -0
- package/.agent/skills/bun-development/SKILL.md +386 -0
- package/.agent/skills/burp-suite-testing/SKILL.md +60 -0
- package/.agent/skills/clerk-auth/SKILL.md +432 -0
- package/.agent/skills/cloud-penetration-testing/SKILL.md +51 -0
- package/.agent/skills/copywriting/SKILL.md +66 -0
- package/.agent/skills/crewai/SKILL.md +470 -0
- package/.agent/skills/decision-memory/SKILL.md +317 -0
- package/.agent/skills/discord-bot-architect/SKILL.md +447 -0
- package/.agent/skills/email-sequence/SKILL.md +73 -0
- package/.agent/skills/emergence-detector/SKILL.md +230 -0
- package/.agent/skills/emergence-detector/scripts/check_emergence.py +265 -0
- package/.agent/skills/ethical-hacking-methodology/SKILL.md +67 -0
- package/.agent/skills/explained-qa/SKILL.md +142 -0
- package/.agent/skills/explained-qa/game-terminology.md +214 -0
- package/.agent/skills/firebase/SKILL.md +377 -0
- package/.agent/skills/game-development/ai-dialogue-engine/SKILL.md +442 -0
- package/.agent/skills/game-development/ai-graphics-generator/SKILL.md +463 -0
- package/.agent/skills/game-development/ai-playtest-framework/SKILL.md +570 -0
- package/.agent/skills/game-development/camera-systems/SKILL.md +607 -0
- package/.agent/skills/game-development/card-battle-engine/SKILL.md +618 -0
- package/.agent/skills/game-development/character-controller-3d/SKILL.md +908 -0
- package/.agent/skills/game-development/cloud-save-sync/SKILL.md +527 -0
- package/.agent/skills/game-development/combat-system/SKILL.md +748 -0
- package/.agent/skills/game-development/compliance-rating/SKILL.md +277 -0
- package/.agent/skills/game-development/crossplatform-build/SKILL.md +386 -0
- package/.agent/skills/game-development/cultivation-progression/SKILL.md +520 -0
- package/.agent/skills/game-development/data-driven-balance/SKILL.md +535 -0
- package/.agent/skills/game-development/game-analytics-integrator/SKILL.md +410 -0
- package/.agent/skills/game-development/game-audio-advanced/SKILL.md +646 -0
- package/.agent/skills/game-development/game-economy-designer/SKILL.md +375 -0
- package/.agent/skills/game-development/game-marketing/SKILL.md +85 -0
- package/.agent/skills/game-development/game-state-manager/SKILL.md +883 -0
- package/.agent/skills/game-development/godot-expert/SKILL.md +462 -0
- package/.agent/skills/game-development/hybrid-game-spec/SKILL.md +220 -0
- package/.agent/skills/game-development/inventory-quest/SKILL.md +747 -0
- package/.agent/skills/game-development/liveops/SKILL.md +308 -0
- package/.agent/skills/game-development/localization/SKILL.md +286 -0
- package/.agent/skills/game-development/mobile-input-patterns/SKILL.md +343 -0
- package/.agent/skills/game-development/monetization-strategy/SKILL.md +94 -0
- package/.agent/skills/game-development/multiplayer-master/SKILL.md +727 -0
- package/.agent/skills/game-development/narrative-branching/SKILL.md +593 -0
- package/.agent/skills/game-development/npc-ai-integration/SKILL.md +110 -0
- package/.agent/skills/game-development/procedural-generation/SKILL.md +168 -0
- package/.agent/skills/game-development/procedural-level-ai/SKILL.md +367 -0
- package/.agent/skills/game-development/prototyping-rapid/SKILL.md +205 -0
- package/.agent/skills/game-development/spec-ecosystem/SKILL.md +155 -0
- package/.agent/skills/game-development/spec-ecosystem/decision-log-format.md +129 -0
- package/.agent/skills/game-development/spec-ecosystem/templates/PLAN-template.md +178 -0
- package/.agent/skills/game-development/spec-ecosystem/templates/SPEC-template.md +110 -0
- package/.agent/skills/game-development/spec-ecosystem/templates/TASKS-template.md +156 -0
- package/.agent/skills/game-development/survival-systems/SKILL.md +493 -0
- package/.agent/skills/game-development/testing-qa/SKILL.md +270 -0
- package/.agent/skills/game-development/unity-integration/SKILL.md +358 -0
- package/.agent/skills/game-development/unity-mobile-optimization/SKILL.md +271 -0
- package/.agent/skills/game-development/webgpu-shading/SKILL.md +209 -0
- package/.agent/skills/gcp-cloud-run/SKILL.md +358 -0
- package/.agent/skills/graphql/SKILL.md +492 -0
- package/.agent/skills/idor-testing/SKILL.md +64 -0
- package/.agent/skills/inngest/SKILL.md +128 -0
- package/.agent/skills/intent-capture/SKILL.md +65 -0
- package/.agent/skills/langfuse/SKILL.md +415 -0
- package/.agent/skills/langgraph/SKILL.md +360 -0
- package/.agent/skills/launch-strategy/SKILL.md +68 -0
- package/.agent/skills/linux-privilege-escalation/SKILL.md +62 -0
- package/.agent/skills/llm-app-patterns/SKILL.md +367 -0
- package/.agent/skills/marketing-ideas/SKILL.md +66 -0
- package/.agent/skills/mcp-composition/SKILL.md +362 -0
- package/.agent/skills/mcp-observability/SKILL.md +323 -0
- package/.agent/skills/mcp-security/SKILL.md +314 -0
- package/.agent/skills/metasploit-framework/SKILL.md +60 -0
- package/.agent/skills/micro-saas-launcher/SKILL.md +93 -0
- package/.agent/skills/neon-postgres/SKILL.md +339 -0
- package/.agent/skills/paid-ads/SKILL.md +64 -0
- package/.agent/skills/supabase-integration/SKILL.md +411 -0
- package/.agent/skills/trust-spectrum/SKILL.md +291 -0
- package/.agent/skills/vibe-coding-guard/SKILL.md +328 -0
- package/.agent/templates/AGENTS.game.md +63 -0
- package/.agent/templates/docs/WORKFLOW_GUIDE.en.md +100 -0
- package/.agent/templates/docs/WORKFLOW_GUIDE.vi.md +100 -0
- package/.agent/workflows/ai-agent.md +38 -0
- package/.agent/workflows/autofix.md +1 -0
- package/.agent/workflows/brainstorm.md +1 -0
- package/.agent/workflows/context.md +1 -0
- package/.agent/workflows/create.md +39 -8
- package/.agent/workflows/dashboard.md +1 -0
- package/.agent/workflows/debug.md +14 -0
- package/.agent/workflows/deploy.md +14 -0
- package/.agent/workflows/enhance.md +44 -0
- package/.agent/workflows/gamekit-init.md +177 -0
- package/.agent/workflows/gamekit-launch.md +338 -0
- package/.agent/workflows/gamekit-plan.md +204 -0
- package/.agent/workflows/gamekit-qa.md +153 -0
- package/.agent/workflows/gamekit-spec.md +243 -0
- package/.agent/workflows/gamekit-tasks.md +208 -0
- package/.agent/workflows/marketing.md +39 -0
- package/.agent/workflows/next.md +1 -0
- package/.agent/workflows/orchestrate.md +12 -0
- package/.agent/workflows/pentest.md +39 -0
- package/.agent/workflows/plan.md +42 -0
- package/.agent/workflows/preview.md +1 -0
- package/.agent/workflows/quality.md +1 -0
- package/.agent/workflows/saas.md +38 -0
- package/.agent/workflows/spec.md +42 -0
- package/.agent/workflows/status.md +1 -0
- package/.agent/workflows/test.md +14 -0
- package/.agent/workflows/ui-ux-pro-max.md +1 -0
- package/README.md +4 -4
- package/bin/cli.js +411 -111
- package/package.json +1 -2
- package/docs/AI_DATA_INFRASTRUCTURE.md +0 -288
- package/docs/CHANGELOG_AI_INFRA.md +0 -111
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* Agent Kit MCP Gateway Server
|
|
3
|
+
* Agent Kit MCP Gateway Server v2.0
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* Enhanced MCP server with:
|
|
6
|
+
* - Dual transport (stdio + Streamable HTTP)
|
|
7
|
+
* - OAuth 2.1 / API Key authentication
|
|
8
|
+
* - OpenTelemetry observability
|
|
9
|
+
* - Semantic search with auto-sync
|
|
10
|
+
*
|
|
11
|
+
* @version 2.0.0
|
|
7
12
|
*/
|
|
8
13
|
|
|
9
14
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -12,17 +17,42 @@ import { z } from "zod";
|
|
|
12
17
|
import * as fs from "fs";
|
|
13
18
|
import * as path from "path";
|
|
14
19
|
|
|
15
|
-
// Import
|
|
20
|
+
// Import modules
|
|
16
21
|
import { IncrementalSyncer, getGlobalDebouncer, TimestampChecker } from "./sync/index.js";
|
|
22
|
+
import { createStreamableHttpTransport, type StreamableHttpOptions } from "./transports/index.js";
|
|
23
|
+
import { createApiKey, validateApiKey, extractApiKey, type AuthResult } from "./auth/index.js";
|
|
24
|
+
import { traceToolCall, getMetrics, initializeTracing } from "./observability/index.js";
|
|
25
|
+
|
|
26
|
+
// ============================================================================
|
|
27
|
+
// Configuration
|
|
28
|
+
// ============================================================================
|
|
17
29
|
|
|
18
|
-
// Get project root from environment or command line
|
|
19
30
|
const PROJECT_ROOT = process.env.PROJECT_ROOT || process.cwd();
|
|
31
|
+
const HTTP_PORT = parseInt(process.env.MCP_HTTP_PORT || "3100", 10);
|
|
32
|
+
const ENABLE_HTTP = process.env.MCP_ENABLE_HTTP === "true";
|
|
33
|
+
const ENABLE_AUTH = process.env.MCP_ENABLE_AUTH === "true";
|
|
34
|
+
const API_KEY = process.env.MCP_API_KEY;
|
|
35
|
+
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Initialize Components
|
|
38
|
+
// ============================================================================
|
|
20
39
|
|
|
21
|
-
// Initialize sync components
|
|
22
40
|
const syncer = new IncrementalSyncer(PROJECT_ROOT);
|
|
23
|
-
const debouncer = getGlobalDebouncer(30000);
|
|
41
|
+
const debouncer = getGlobalDebouncer(30000);
|
|
24
42
|
const timestampChecker = new TimestampChecker(PROJECT_ROOT);
|
|
25
43
|
|
|
44
|
+
// Initialize tracing
|
|
45
|
+
initializeTracing({
|
|
46
|
+
serviceName: "agent-kit-mcp",
|
|
47
|
+
serviceVersion: "2.0.0",
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Create default API key if provided via env
|
|
51
|
+
if (API_KEY) {
|
|
52
|
+
createApiKey("default", ["read:project", "read:graph", "read:search", "write:sync"]);
|
|
53
|
+
console.error(`[MCP] API key configured from environment`);
|
|
54
|
+
}
|
|
55
|
+
|
|
26
56
|
// ============================================================================
|
|
27
57
|
// Auto-Sync Helper
|
|
28
58
|
// ============================================================================
|
|
@@ -70,7 +100,7 @@ function readTextFile(filePath: string): string | null {
|
|
|
70
100
|
|
|
71
101
|
const server = new McpServer({
|
|
72
102
|
name: "agent-kit-gateway",
|
|
73
|
-
version: "
|
|
103
|
+
version: "2.0.0",
|
|
74
104
|
});
|
|
75
105
|
|
|
76
106
|
// ============================================================================
|
|
@@ -84,38 +114,40 @@ server.tool(
|
|
|
84
114
|
section: z.enum(["all", "tech_stack", "structure", "conventions", "commands"]).optional().default("all")
|
|
85
115
|
},
|
|
86
116
|
async ({ section }) => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const sections: Record<string, string> = {};
|
|
95
|
-
const lines = agentsMd.split("\n");
|
|
96
|
-
let currentSection = "";
|
|
97
|
-
let currentContent: string[] = [];
|
|
98
|
-
|
|
99
|
-
for (const line of lines) {
|
|
100
|
-
if (line.startsWith("## ")) {
|
|
101
|
-
if (currentSection) sections[currentSection] = currentContent.join("\n").trim();
|
|
102
|
-
currentSection = line.replace("## ", "").trim();
|
|
103
|
-
currentContent = [];
|
|
104
|
-
} else {
|
|
105
|
-
currentContent.push(line);
|
|
117
|
+
return traceToolCall("get_project_context", { section }, async () => {
|
|
118
|
+
const agentsMd = readTextFile("AGENTS.md");
|
|
119
|
+
if (!agentsMd) {
|
|
120
|
+
return {
|
|
121
|
+
content: [{ type: "text" as const, text: "AGENTS.md not found. Run 'ak init' first." }]
|
|
122
|
+
};
|
|
106
123
|
}
|
|
107
|
-
}
|
|
108
|
-
if (currentSection) sections[currentSection] = currentContent.join("\n").trim();
|
|
109
|
-
|
|
110
|
-
const sectionMap: Record<string, string | undefined> = {
|
|
111
|
-
tech_stack: sections["🛠️ Tech Stack"] || sections["Tech Stack"],
|
|
112
|
-
structure: sections["📁 Directory Map"] || sections["Directory Map"],
|
|
113
|
-
conventions: sections["📜 Rules & Conventions"] || sections["Rules & Conventions"],
|
|
114
|
-
commands: sections["🔧 Commands Reference"] || sections["Commands Reference"],
|
|
115
|
-
all: agentsMd,
|
|
116
|
-
};
|
|
117
124
|
|
|
118
|
-
|
|
125
|
+
const sections: Record<string, string> = {};
|
|
126
|
+
const lines = agentsMd.split("\n");
|
|
127
|
+
let currentSection = "";
|
|
128
|
+
let currentContent: string[] = [];
|
|
129
|
+
|
|
130
|
+
for (const line of lines) {
|
|
131
|
+
if (line.startsWith("## ")) {
|
|
132
|
+
if (currentSection) sections[currentSection] = currentContent.join("\n").trim();
|
|
133
|
+
currentSection = line.replace("## ", "").trim();
|
|
134
|
+
currentContent = [];
|
|
135
|
+
} else {
|
|
136
|
+
currentContent.push(line);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (currentSection) sections[currentSection] = currentContent.join("\n").trim();
|
|
140
|
+
|
|
141
|
+
const sectionMap: Record<string, string | undefined> = {
|
|
142
|
+
tech_stack: sections["🛠️ Tech Stack"] || sections["Tech Stack"],
|
|
143
|
+
structure: sections["📁 Directory Map"] || sections["Directory Map"],
|
|
144
|
+
conventions: sections["📜 Rules & Conventions"] || sections["Rules & Conventions"],
|
|
145
|
+
commands: sections["🔧 Commands Reference"] || sections["Commands Reference"],
|
|
146
|
+
all: agentsMd,
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
return { content: [{ type: "text" as const, text: sectionMap[section] || agentsMd }] };
|
|
150
|
+
});
|
|
119
151
|
}
|
|
120
152
|
);
|
|
121
153
|
|
|
@@ -128,22 +160,24 @@ server.tool(
|
|
|
128
160
|
"Get high-level project summary: Code vs Docs distribution, primary types, and impact analysis.",
|
|
129
161
|
{},
|
|
130
162
|
async () => {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
163
|
+
return traceToolCall("get_project_intelligence", {}, async () => {
|
|
164
|
+
const graph = readJsonFile(".agent/graph.json");
|
|
165
|
+
if (!graph) return { content: [{ type: "text" as const, text: "Project data not generated." }] };
|
|
166
|
+
|
|
167
|
+
const stats = graph.metadata?.file_types || {};
|
|
168
|
+
const total = graph.metadata?.total_files || 1;
|
|
169
|
+
const docCount = (stats.documentation || 0) + (stats.document || 0) + (stats.readme || 0);
|
|
170
|
+
const codeCount = (stats.component || 0) + (stats.module || 0) + (stats.utility || 0);
|
|
171
|
+
|
|
172
|
+
const intelligence = {
|
|
173
|
+
project_name: path.basename(PROJECT_ROOT),
|
|
174
|
+
project_type: docCount > codeCount ? "Documentation-Heavy" : "Code-Centric",
|
|
175
|
+
distribution: { docs: `${Math.round((docCount / total) * 100)}%`, code: `${Math.round((codeCount / total) * 100)}%` },
|
|
176
|
+
top_files: graph.nodes?.slice(0, 5).map((n: any) => n.id)
|
|
177
|
+
};
|
|
145
178
|
|
|
146
|
-
|
|
179
|
+
return { content: [{ type: "text" as const, text: JSON.stringify(intelligence, null, 2) }] };
|
|
180
|
+
});
|
|
147
181
|
}
|
|
148
182
|
);
|
|
149
183
|
|
|
@@ -159,25 +193,27 @@ server.tool(
|
|
|
159
193
|
direction: z.enum(["imports", "imported_by", "both"]).optional().default("both")
|
|
160
194
|
},
|
|
161
195
|
async ({ file_path, direction }) => {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
196
|
+
return traceToolCall("analyze_dependencies", { file_path, direction }, async () => {
|
|
197
|
+
await autoSyncIfNeeded();
|
|
198
|
+
const graph = readJsonFile(".agent/graph.json");
|
|
199
|
+
if (!graph) return { content: [{ type: "text" as const, text: "Graph not found." }] };
|
|
200
|
+
|
|
201
|
+
const normalizedPath = file_path.replace(/^\.\//, "");
|
|
202
|
+
const node = graph.nodes?.find((n: any) => n.id === normalizedPath);
|
|
203
|
+
if (!node) return { content: [{ type: "text" as const, text: "File not found in graph." }] };
|
|
204
|
+
|
|
205
|
+
const isDoc = ["documentation", "readme", "document"].includes(node.type);
|
|
206
|
+
const outLabel = isDoc ? "references" : "imports";
|
|
207
|
+
const inLabel = isDoc ? "referenced_by" : "imported_by";
|
|
208
|
+
|
|
209
|
+
const result: any = { file: normalizedPath, type: node.type };
|
|
210
|
+
if (direction !== "imported_by") result[outLabel] = node.imports || [];
|
|
211
|
+
if (direction !== "imports") {
|
|
212
|
+
result[inLabel] = graph.edges?.filter((e: any) => e.target === normalizedPath).map((e: any) => e.source) || [];
|
|
213
|
+
}
|
|
179
214
|
|
|
180
|
-
|
|
215
|
+
return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }] };
|
|
216
|
+
});
|
|
181
217
|
}
|
|
182
218
|
);
|
|
183
219
|
|
|
@@ -186,29 +222,31 @@ server.tool(
|
|
|
186
222
|
// ============================================================================
|
|
187
223
|
|
|
188
224
|
async function handleSearch(args: { query: string, file_filter?: string, top_k: number }) {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
225
|
+
return traceToolCall("search_knowledge", args, async () => {
|
|
226
|
+
await autoSyncIfNeeded();
|
|
227
|
+
const chunks = readJsonFile(".agent/rag/chunks.json");
|
|
228
|
+
if (!chunks?.chunks) return { content: [{ type: "text" as const, text: "No chunks found." }] };
|
|
229
|
+
|
|
230
|
+
const query = args.query.toLowerCase();
|
|
231
|
+
const results = chunks.chunks
|
|
232
|
+
.map((chunk: any) => {
|
|
233
|
+
let score = 0;
|
|
234
|
+
const content = chunk.content.toLowerCase();
|
|
235
|
+
if (content.includes(query)) score += 5;
|
|
236
|
+
if (chunk.metadata.name?.toLowerCase().includes(query)) score += 10;
|
|
237
|
+
return { chunk, score };
|
|
238
|
+
})
|
|
239
|
+
.filter((s: any) => s.score > 0)
|
|
240
|
+
.sort((a: any, b: any) => b.score - a.score)
|
|
241
|
+
.slice(0, args.top_k)
|
|
242
|
+
.map((s: any) => ({
|
|
243
|
+
file: s.chunk.metadata.file_path,
|
|
244
|
+
context: s.chunk.metadata.context_path || s.chunk.metadata.name,
|
|
245
|
+
preview: s.chunk.content.substring(0, 250) + "..."
|
|
246
|
+
}));
|
|
247
|
+
|
|
248
|
+
return { content: [{ type: "text" as const, text: JSON.stringify(results, null, 2) }] };
|
|
249
|
+
});
|
|
212
250
|
}
|
|
213
251
|
|
|
214
252
|
server.tool(
|
|
@@ -242,16 +280,104 @@ server.tool(
|
|
|
242
280
|
"Find files affected by changing a file.",
|
|
243
281
|
{ file_path: z.string() },
|
|
244
282
|
async ({ file_path }) => {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
283
|
+
return traceToolCall("get_impact_zone", { file_path }, async () => {
|
|
284
|
+
await autoSyncIfNeeded();
|
|
285
|
+
const graph = readJsonFile(".agent/graph.json");
|
|
286
|
+
if (!graph) return { content: [{ type: "text" as const, text: "Graph not found." }] };
|
|
287
|
+
|
|
288
|
+
const normalizedPath = file_path.replace(/^\.\//, "");
|
|
289
|
+
const affected = graph.edges
|
|
290
|
+
?.filter((e: any) => e.target === normalizedPath)
|
|
291
|
+
.map((e: any) => e.source) || [];
|
|
292
|
+
|
|
293
|
+
return { content: [{ type: "text" as const, text: JSON.stringify({ file: normalizedPath, affected }, null, 2) }] };
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
);
|
|
248
297
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
.map((e: any) => e.source) || [];
|
|
298
|
+
// ============================================================================
|
|
299
|
+
// Tool: force_sync (NEW)
|
|
300
|
+
// ============================================================================
|
|
253
301
|
|
|
254
|
-
|
|
302
|
+
server.tool(
|
|
303
|
+
"force_sync",
|
|
304
|
+
"Force refresh all AI data (graph, chunks, AGENTS.md)",
|
|
305
|
+
{
|
|
306
|
+
target: z.enum(["all", "graph", "rag", "agents_md"]).optional().default("all")
|
|
307
|
+
},
|
|
308
|
+
async ({ target }) => {
|
|
309
|
+
return traceToolCall("force_sync", { target }, async () => {
|
|
310
|
+
const result = await syncer.syncAll();
|
|
311
|
+
return {
|
|
312
|
+
content: [{
|
|
313
|
+
type: "text" as const,
|
|
314
|
+
text: JSON.stringify({
|
|
315
|
+
success: true,
|
|
316
|
+
target,
|
|
317
|
+
...result
|
|
318
|
+
}, null, 2)
|
|
319
|
+
}]
|
|
320
|
+
};
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
// ============================================================================
|
|
326
|
+
// Tool: get_metrics (NEW - Observability)
|
|
327
|
+
// ============================================================================
|
|
328
|
+
|
|
329
|
+
server.tool(
|
|
330
|
+
"get_metrics",
|
|
331
|
+
"Get MCP server performance metrics",
|
|
332
|
+
{},
|
|
333
|
+
async () => {
|
|
334
|
+
return traceToolCall("get_metrics", {}, async () => {
|
|
335
|
+
const metrics = getMetrics();
|
|
336
|
+
return {
|
|
337
|
+
content: [{
|
|
338
|
+
type: "text" as const,
|
|
339
|
+
text: JSON.stringify(metrics, null, 2)
|
|
340
|
+
}]
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
);
|
|
345
|
+
|
|
346
|
+
// ============================================================================
|
|
347
|
+
// Tool: get_server_info (NEW)
|
|
348
|
+
// ============================================================================
|
|
349
|
+
|
|
350
|
+
server.tool(
|
|
351
|
+
"get_server_info",
|
|
352
|
+
"Get MCP server information and capabilities",
|
|
353
|
+
{},
|
|
354
|
+
async () => {
|
|
355
|
+
return {
|
|
356
|
+
content: [{
|
|
357
|
+
type: "text" as const,
|
|
358
|
+
text: JSON.stringify({
|
|
359
|
+
name: "agent-kit-gateway",
|
|
360
|
+
version: "2.0.0",
|
|
361
|
+
features: {
|
|
362
|
+
transport: ENABLE_HTTP ? ["stdio", "streamable-http"] : ["stdio"],
|
|
363
|
+
auth: ENABLE_AUTH ? ["api-key", "oauth2.1"] : ["none"],
|
|
364
|
+
observability: ["opentelemetry", "metrics"],
|
|
365
|
+
},
|
|
366
|
+
tools: [
|
|
367
|
+
"get_project_context",
|
|
368
|
+
"get_project_intelligence",
|
|
369
|
+
"analyze_dependencies",
|
|
370
|
+
"search_knowledge",
|
|
371
|
+
"search_code_logic",
|
|
372
|
+
"get_impact_zone",
|
|
373
|
+
"force_sync",
|
|
374
|
+
"get_metrics",
|
|
375
|
+
"get_server_info",
|
|
376
|
+
],
|
|
377
|
+
project_root: PROJECT_ROOT,
|
|
378
|
+
}, null, 2)
|
|
379
|
+
}]
|
|
380
|
+
};
|
|
255
381
|
}
|
|
256
382
|
);
|
|
257
383
|
|
|
@@ -260,11 +386,32 @@ server.tool(
|
|
|
260
386
|
// ============================================================================
|
|
261
387
|
|
|
262
388
|
async function main() {
|
|
263
|
-
|
|
264
|
-
|
|
389
|
+
console.error("[MCP] Agent Kit Gateway v2.0.0 starting...");
|
|
390
|
+
console.error(`[MCP] Project root: ${PROJECT_ROOT}`);
|
|
391
|
+
|
|
392
|
+
// Start stdio transport (always)
|
|
393
|
+
const stdioTransport = new StdioServerTransport();
|
|
394
|
+
await server.connect(stdioTransport);
|
|
395
|
+
console.error("[MCP] stdio transport connected");
|
|
396
|
+
|
|
397
|
+
// Optionally start HTTP transport
|
|
398
|
+
if (ENABLE_HTTP) {
|
|
399
|
+
const httpOptions: StreamableHttpOptions = {
|
|
400
|
+
port: HTTP_PORT,
|
|
401
|
+
enableSSE: true,
|
|
402
|
+
stateless: true,
|
|
403
|
+
enableAuth: ENABLE_AUTH,
|
|
404
|
+
corsOrigins: process.env.MCP_CORS_ORIGINS?.split(",") || [],
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
await createStreamableHttpTransport(httpOptions);
|
|
408
|
+
console.error(`[MCP] Streamable HTTP transport available on port ${HTTP_PORT}`);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
console.error("[MCP] Gateway ready!");
|
|
265
412
|
}
|
|
266
413
|
|
|
267
414
|
main().catch(err => {
|
|
268
|
-
console.error(err);
|
|
415
|
+
console.error("[MCP] Fatal error:", err);
|
|
269
416
|
process.exit(1);
|
|
270
417
|
});
|