agentic-knowledge-mcp 0.0.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.
Files changed (77) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +530 -0
  3. package/package.json +94 -0
  4. package/packages/cli/dist/cli.d.ts +5 -0
  5. package/packages/cli/dist/cli.js +21 -0
  6. package/packages/cli/dist/commands/create.d.ts +5 -0
  7. package/packages/cli/dist/commands/create.js +90 -0
  8. package/packages/cli/dist/commands/init.d.ts +5 -0
  9. package/packages/cli/dist/commands/init.js +182 -0
  10. package/packages/cli/dist/commands/refresh.d.ts +5 -0
  11. package/packages/cli/dist/commands/refresh.js +322 -0
  12. package/packages/cli/dist/commands/status.d.ts +5 -0
  13. package/packages/cli/dist/commands/status.js +268 -0
  14. package/packages/cli/dist/index.d.ts +6 -0
  15. package/packages/cli/dist/index.js +6 -0
  16. package/packages/cli/package.json +57 -0
  17. package/packages/content-loader/dist/__tests__/debug-filtering.d.ts +1 -0
  18. package/packages/content-loader/dist/__tests__/debug-filtering.js +17 -0
  19. package/packages/content-loader/dist/__tests__/test-filtering.d.ts +1 -0
  20. package/packages/content-loader/dist/__tests__/test-filtering.js +19 -0
  21. package/packages/content-loader/dist/content/api-documentation-loader.d.ts +26 -0
  22. package/packages/content-loader/dist/content/api-documentation-loader.js +45 -0
  23. package/packages/content-loader/dist/content/content-processor.d.ts +44 -0
  24. package/packages/content-loader/dist/content/content-processor.js +86 -0
  25. package/packages/content-loader/dist/content/documentation-site-loader.d.ts +26 -0
  26. package/packages/content-loader/dist/content/documentation-site-loader.js +45 -0
  27. package/packages/content-loader/dist/content/git-repo-loader.d.ts +79 -0
  28. package/packages/content-loader/dist/content/git-repo-loader.js +368 -0
  29. package/packages/content-loader/dist/content/index.d.ts +9 -0
  30. package/packages/content-loader/dist/content/index.js +9 -0
  31. package/packages/content-loader/dist/content/loader.d.ts +47 -0
  32. package/packages/content-loader/dist/content/loader.js +8 -0
  33. package/packages/content-loader/dist/content/metadata-manager.d.ts +65 -0
  34. package/packages/content-loader/dist/content/metadata-manager.js +160 -0
  35. package/packages/content-loader/dist/index.d.ts +5 -0
  36. package/packages/content-loader/dist/index.js +5 -0
  37. package/packages/content-loader/dist/types.d.ts +127 -0
  38. package/packages/content-loader/dist/types.js +48 -0
  39. package/packages/content-loader/package.json +50 -0
  40. package/packages/core/dist/config/discovery.d.ts +15 -0
  41. package/packages/core/dist/config/discovery.js +65 -0
  42. package/packages/core/dist/config/loader.d.ts +22 -0
  43. package/packages/core/dist/config/loader.js +236 -0
  44. package/packages/core/dist/config/manager.d.ts +55 -0
  45. package/packages/core/dist/config/manager.js +180 -0
  46. package/packages/core/dist/content/api-documentation-loader.d.ts +26 -0
  47. package/packages/core/dist/content/api-documentation-loader.js +45 -0
  48. package/packages/core/dist/content/content-processor.d.ts +44 -0
  49. package/packages/core/dist/content/content-processor.js +81 -0
  50. package/packages/core/dist/content/documentation-site-loader.d.ts +26 -0
  51. package/packages/core/dist/content/documentation-site-loader.js +45 -0
  52. package/packages/core/dist/content/git-repo-loader.d.ts +54 -0
  53. package/packages/core/dist/content/git-repo-loader.js +264 -0
  54. package/packages/core/dist/content/index.d.ts +9 -0
  55. package/packages/core/dist/content/index.js +9 -0
  56. package/packages/core/dist/content/loader.d.ts +50 -0
  57. package/packages/core/dist/content/loader.js +7 -0
  58. package/packages/core/dist/content/metadata-manager.d.ts +65 -0
  59. package/packages/core/dist/content/metadata-manager.js +160 -0
  60. package/packages/core/dist/index.d.ts +12 -0
  61. package/packages/core/dist/index.js +30 -0
  62. package/packages/core/dist/paths/calculator.d.ts +46 -0
  63. package/packages/core/dist/paths/calculator.js +166 -0
  64. package/packages/core/dist/templates/processor.d.ts +40 -0
  65. package/packages/core/dist/templates/processor.js +111 -0
  66. package/packages/core/dist/types.d.ts +129 -0
  67. package/packages/core/dist/types.js +79 -0
  68. package/packages/core/package.json +50 -0
  69. package/packages/mcp-server/dist/bin.d.ts +5 -0
  70. package/packages/mcp-server/dist/bin.js +10 -0
  71. package/packages/mcp-server/dist/cli.d.ts +7 -0
  72. package/packages/mcp-server/dist/cli.js +17 -0
  73. package/packages/mcp-server/dist/index.d.ts +8 -0
  74. package/packages/mcp-server/dist/index.js +9 -0
  75. package/packages/mcp-server/dist/server.d.ts +35 -0
  76. package/packages/mcp-server/dist/server.js +244 -0
  77. package/packages/mcp-server/package.json +54 -0
@@ -0,0 +1,17 @@
1
+ /**
2
+ * CLI functionality for the MCP server
3
+ */
4
+ import { startMCPServer } from "./server.js";
5
+ /**
6
+ * Start the agentic knowledge MCP server from CLI
7
+ */
8
+ export async function startServer() {
9
+ try {
10
+ await startMCPServer();
11
+ }
12
+ catch (error) {
13
+ const errorMessage = error instanceof Error ? error.message : String(error);
14
+ console.error("Failed to start agentic-knowledge server:", errorMessage);
15
+ process.exit(1);
16
+ }
17
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @codemcp/knowledge-mcp-server
3
+ *
4
+ * MCP server implementation for the agentic knowledge guidance system.
5
+ * Provides search_docs and list_docsets tools via the Model Context Protocol.
6
+ */
7
+ export { createAgenticKnowledgeServer, startMCPServer } from "./server.js";
8
+ export { startServer } from "./cli.js";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @codemcp/knowledge-mcp-server
3
+ *
4
+ * MCP server implementation for the agentic knowledge guidance system.
5
+ * Provides search_docs and list_docsets tools via the Model Context Protocol.
6
+ */
7
+ // Export the main server functionality
8
+ export { createAgenticKnowledgeServer, startMCPServer } from "./server.js";
9
+ export { startServer } from "./cli.js";
@@ -0,0 +1,35 @@
1
+ /**
2
+ * MCP Server implementation
3
+ */
4
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
5
+ /**
6
+ * Create an agentic knowledge MCP server
7
+ * @returns MCP server instance
8
+ */
9
+ export declare function createAgenticKnowledgeServer(): Server<{
10
+ method: string;
11
+ params?: {
12
+ [x: string]: unknown;
13
+ _meta?: {
14
+ [x: string]: unknown;
15
+ progressToken?: string | number | undefined;
16
+ } | undefined;
17
+ } | undefined;
18
+ }, {
19
+ method: string;
20
+ params?: {
21
+ [x: string]: unknown;
22
+ _meta?: {
23
+ [x: string]: unknown;
24
+ } | undefined;
25
+ } | undefined;
26
+ }, {
27
+ [x: string]: unknown;
28
+ _meta?: {
29
+ [x: string]: unknown;
30
+ } | undefined;
31
+ }>;
32
+ /**
33
+ * Start the MCP server with stdio transport
34
+ */
35
+ export declare function startMCPServer(): Promise<void>;
@@ -0,0 +1,244 @@
1
+ /**
2
+ * MCP Server implementation
3
+ */
4
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
5
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
7
+ import { loadConfig, findConfigPath, calculateLocalPath, processTemplate, createTemplateContext, getEffectiveTemplate, } from "@codemcp/knowledge-core";
8
+ /**
9
+ * Create an agentic knowledge MCP server
10
+ * @returns MCP server instance
11
+ */
12
+ export function createAgenticKnowledgeServer() {
13
+ const server = new Server({
14
+ name: "agentic-knowledge",
15
+ version: "0.1.0",
16
+ }, {
17
+ capabilities: {
18
+ tools: {},
19
+ },
20
+ });
21
+ // Cache for configuration to avoid repeated loading
22
+ let configCache = null;
23
+ let configLoadTime = 0;
24
+ const CONFIG_CACHE_TTL = 60000; // 1 minute cache
25
+ /**
26
+ * Load configuration with caching
27
+ */
28
+ async function getConfiguration() {
29
+ const now = Date.now();
30
+ if (configCache && now - configLoadTime < CONFIG_CACHE_TTL) {
31
+ return configCache;
32
+ }
33
+ try {
34
+ // Find configuration file path
35
+ const configPath = await findConfigPath();
36
+ if (!configPath) {
37
+ throw new Error("No configuration file found. Please create a .knowledge/config.yaml file in your project.");
38
+ }
39
+ // Load configuration
40
+ const config = await loadConfig(configPath);
41
+ // Cache result
42
+ configCache = { config, configPath };
43
+ configLoadTime = now;
44
+ return configCache;
45
+ }
46
+ catch (error) {
47
+ // Clear cache on error to force retry next time
48
+ configCache = null;
49
+ configLoadTime = 0;
50
+ throw error;
51
+ }
52
+ }
53
+ // Register tool handlers
54
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
55
+ try {
56
+ // Load configuration to get available docsets
57
+ const { config } = await getConfiguration();
58
+ // Build rich description with available docsets
59
+ const docsetInfo = config.docsets
60
+ .map((docset) => {
61
+ const description = docset.description
62
+ ? ` - ${docset.description}`
63
+ : "";
64
+ return `• **${docset.id}** (${docset.name})${description}`;
65
+ })
66
+ .join("\n");
67
+ const searchDocsDescription = `Search for documentation in available docsets. Returns structured search strategy.
68
+
69
+ 📚 **AVAILABLE DOCSETS:**
70
+ ${docsetInfo}
71
+
72
+ 🔍 **SEARCH STRATEGY:**
73
+ - Use the tools you have to search in text files (grep, rg, ripgrep, find)
74
+ - Start with specific terms, expand to generalized terms`;
75
+ return {
76
+ tools: [
77
+ {
78
+ name: "search_docs",
79
+ description: searchDocsDescription,
80
+ inputSchema: {
81
+ type: "object",
82
+ properties: {
83
+ docset_id: {
84
+ type: "string",
85
+ description: "Choose the docset to search in.",
86
+ enum: config.docsets.map((d) => d.id),
87
+ },
88
+ keywords: {
89
+ type: "string",
90
+ description: 'Primary search terms or concepts you\'re looking for. Be specific about what you want to find (e.g., "authentication middleware", "user validation", "API rate limiting"). Include the exact terms you expect to appear in the documentation.',
91
+ },
92
+ generalized_keywords: {
93
+ type: "string",
94
+ description: 'Related terms, synonyms, or contextual keywords that may appear alongside your primary keywords but are not your main target. These help broaden the search context and catch relevant content that might use different terminology (e.g., for "authentication" you might include "login, signin, oauth, credentials, tokens"). Think of terms that would appear in the same sections or discussions as your main keywords.',
95
+ },
96
+ },
97
+ required: ["docset_id", "keywords"],
98
+ additionalProperties: false,
99
+ },
100
+ },
101
+ {
102
+ name: "list_docsets",
103
+ description: "List all available documentation sets (docsets) with detailed information. Note: The search_docs tool already shows available docsets in its description, so this tool is mainly for getting additional metadata.",
104
+ inputSchema: {
105
+ type: "object",
106
+ properties: {},
107
+ additionalProperties: false,
108
+ },
109
+ },
110
+ ],
111
+ };
112
+ }
113
+ catch (error) {
114
+ // Fallback to basic tools if configuration fails
115
+ return {
116
+ tools: [
117
+ {
118
+ name: "search_docs",
119
+ description: "Search for documentation guidance based on keywords and context. Returns intelligent navigation instructions to help you find relevant information in a specific docset. (Configuration error - use list_docsets to see available options)",
120
+ inputSchema: {
121
+ type: "object",
122
+ properties: {
123
+ docset_id: {
124
+ type: "string",
125
+ description: "The identifier of the docset to search in. Use list_docsets to see available options.",
126
+ },
127
+ keywords: {
128
+ type: "string",
129
+ description: 'Primary search terms or concepts you\'re looking for. Be specific about what you want to find (e.g., "authentication middleware", "user validation", "API rate limiting"). Include the exact terms you expect to appear in the documentation.',
130
+ },
131
+ generalized_keywords: {
132
+ type: "string",
133
+ description: 'Related terms, synonyms, or contextual keywords that may appear alongside your primary keywords but are not your main target. These help broaden the search context and catch relevant content that might use different terminology (e.g., for "authentication" you might include "login, signin, oauth, credentials, tokens"). Think of terms that would appear in the same sections or discussions as your main keywords.',
134
+ },
135
+ },
136
+ required: ["docset_id", "keywords"],
137
+ additionalProperties: false,
138
+ },
139
+ },
140
+ {
141
+ name: "list_docsets",
142
+ description: "List all available documentation sets (docsets) that can be searched. Each docset represents a specific project, library, or knowledge base.",
143
+ inputSchema: {
144
+ type: "object",
145
+ properties: {},
146
+ additionalProperties: false,
147
+ },
148
+ },
149
+ ],
150
+ };
151
+ }
152
+ });
153
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
154
+ const { name, arguments: args } = request.params;
155
+ try {
156
+ switch (name) {
157
+ case "search_docs": {
158
+ const { docset_id, keywords, generalized_keywords } = args;
159
+ // Validate required parameters
160
+ if (!docset_id || typeof docset_id !== "string") {
161
+ throw new Error("docset_id is required and must be a string");
162
+ }
163
+ if (!keywords || typeof keywords !== "string") {
164
+ throw new Error("keywords is required and must be a string");
165
+ }
166
+ // Load configuration
167
+ const { config, configPath } = await getConfiguration();
168
+ // Find the requested docset
169
+ const docset = config.docsets.find((d) => d.id === docset_id);
170
+ if (!docset) {
171
+ const availableIds = config.docsets.map((d) => d.id).join(", ");
172
+ throw new Error(`Docset '${docset_id}' not found. Available docsets: ${availableIds}`);
173
+ }
174
+ // Calculate local path
175
+ const localPath = calculateLocalPath(docset, configPath);
176
+ // Create template context with proper function signature
177
+ const templateContext = createTemplateContext(localPath, keywords.trim(), (generalized_keywords || "").trim(), docset);
178
+ // Get effective template and process it
179
+ const effectiveTemplate = getEffectiveTemplate(docset, config.template);
180
+ const instructions = processTemplate(effectiveTemplate, templateContext);
181
+ return {
182
+ content: [
183
+ {
184
+ type: "text",
185
+ text: instructions,
186
+ },
187
+ ],
188
+ };
189
+ }
190
+ case "list_docsets": {
191
+ // Load configuration
192
+ const { config } = await getConfiguration();
193
+ // Return list of available docsets
194
+ const docsets = config.docsets.map((docset) => ({
195
+ docset_id: docset.id,
196
+ docset_name: docset.name,
197
+ docset_description: docset.description || "No description provided",
198
+ local_path: docset.local_path,
199
+ }));
200
+ const summary = `Found ${docsets.length} available docset(s):\n\n` +
201
+ docsets
202
+ .map((d) => `**${d.docset_id}** (${d.docset_name})\n` +
203
+ ` Description: ${d.docset_description}\n` +
204
+ ` Path: ${d.local_path}`)
205
+ .join("\n\n");
206
+ return {
207
+ content: [
208
+ {
209
+ type: "text",
210
+ text: summary,
211
+ },
212
+ ],
213
+ };
214
+ }
215
+ default:
216
+ throw new Error(`Unknown tool: ${name}`);
217
+ }
218
+ }
219
+ catch (error) {
220
+ // Return structured error information
221
+ const errorMessage = error instanceof Error ? error.message : String(error);
222
+ return {
223
+ content: [
224
+ {
225
+ type: "text",
226
+ text: `Error: ${errorMessage}`,
227
+ },
228
+ ],
229
+ isError: true,
230
+ };
231
+ }
232
+ });
233
+ return server;
234
+ }
235
+ /**
236
+ * Start the MCP server with stdio transport
237
+ */
238
+ export async function startMCPServer() {
239
+ const server = createAgenticKnowledgeServer();
240
+ const transport = new StdioServerTransport();
241
+ await server.connect(transport);
242
+ // Log startup to stderr so it doesn't interfere with MCP protocol
243
+ console.error("Agentic Knowledge MCP Server started");
244
+ }
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@codemcp/knowledge-mcp-server",
3
+ "version": "0.0.1",
4
+ "description": "MCP server implementation for agentic knowledge guidance system",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "bin": {
9
+ "agentic-knowledge": "./dist/bin.js"
10
+ },
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.build.json",
22
+ "build:watch": "tsc -p tsconfig.build.json --watch",
23
+ "clean": "rimraf dist",
24
+ "dev": "tsc -p tsconfig.build.json --watch",
25
+ "start": "node dist/bin.js",
26
+ "lint": "oxlint && eslint .",
27
+ "lint:fix": "oxlint --fix && eslint . --fix",
28
+ "format:check": "prettier --check .",
29
+ "format:fix": "prettier --write .",
30
+ "test": "vitest run",
31
+ "test:watch": "vitest",
32
+ "test:coverage": "vitest run --coverage",
33
+ "typecheck": "tsc --noEmit"
34
+ },
35
+ "dependencies": {
36
+ "@codemcp/knowledge-core": "workspace:*",
37
+ "@modelcontextprotocol/sdk": "^1.19.1"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^24.3.0",
41
+ "rimraf": "^6.0.1",
42
+ "typescript": "^5.9.2",
43
+ "vitest": "^3.2.4"
44
+ },
45
+ "keywords": [
46
+ "agentic",
47
+ "knowledge",
48
+ "mcp",
49
+ "server",
50
+ "guidance"
51
+ ],
52
+ "author": "Oliver Jägle <github@beimir.net>",
53
+ "license": "MIT"
54
+ }