@runcontext/mcp 0.3.2 → 0.3.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eric Kittelson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # @runcontext/mcp
2
+
3
+ MCP server for [ContextKit](https://github.com/erickittelson/ContextKit) — expose AI-ready metadata to agents via the [Model Context Protocol](https://modelcontextprotocol.io).
4
+
5
+ ## What it does
6
+
7
+ Serves your ContextKit metadata graph — models, governance, glossary, golden queries, guardrails, business rules — to AI agents over MCP. Agents get structured semantic context instead of guessing from raw schemas.
8
+
9
+ ## Usage
10
+
11
+ Usually accessed through the CLI:
12
+
13
+ ```bash
14
+ # stdio transport (for Claude Code, Cursor, etc.)
15
+ npx @runcontext/cli serve --stdio
16
+
17
+ # HTTP transport (for multi-agent or remote setups)
18
+ npx @runcontext/cli serve --http --port 3000
19
+ ```
20
+
21
+ ## Resources
22
+
23
+ | Resource | Description |
24
+ |---|---|
25
+ | `context://manifest` | Full compiled manifest with all models, governance, and rules |
26
+ | `context://model/{name}` | Single model with datasets, fields, relationships, metrics |
27
+ | `context://glossary` | All business term definitions and synonyms |
28
+ | `context://tier/{name}` | Tier scorecard for a model |
29
+
30
+ ## Tools
31
+
32
+ | Tool | Description |
33
+ |---|---|
34
+ | `context_search` | Full-text search across models, fields, terms, and owners |
35
+ | `context_explain` | Look up any entity by name and get full details |
36
+ | `context_validate` | Run lint rules and return diagnostics |
37
+ | `context_tier` | Get the current tier scorecard |
38
+ | `context_golden_queries` | Retrieve curated SQL templates for a model |
39
+ | `context_guardrails` | Get required filters and business rules for safe queries |
40
+
41
+ ## Configure in Claude Code
42
+
43
+ `.claude/mcp.json`:
44
+
45
+ ```json
46
+ {
47
+ "mcpServers": {
48
+ "contextkit": {
49
+ "command": "npx",
50
+ "args": ["@runcontext/cli", "serve", "--stdio"]
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ Or HTTP mode:
57
+
58
+ ```json
59
+ {
60
+ "mcpServers": {
61
+ "contextkit": {
62
+ "url": "http://localhost:3000/mcp"
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+ ## Part of ContextKit
69
+
70
+ See the [ContextKit repository](https://github.com/erickittelson/ContextKit) for full documentation.
71
+
72
+ ## License
73
+
74
+ MIT
package/dist/index.cjs CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/server.ts
2
2
  var _mcpjs = require('@modelcontextprotocol/sdk/server/mcp.js');
3
3
  var _stdiojs = require('@modelcontextprotocol/sdk/server/stdio.js');
4
+ var _streamableHttpjs = require('@modelcontextprotocol/sdk/server/streamableHttp.js');
5
+ var _expressjs = require('@modelcontextprotocol/sdk/server/express.js');
4
6
  var _core = require('@runcontext/core');
5
7
 
6
8
  // src/resources/manifest.ts
@@ -437,6 +439,60 @@ async function startServer(options) {
437
439
  await server.connect(transport);
438
440
  return server;
439
441
  }
442
+ async function startServerHttp(options) {
443
+ const rootDir = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _42 => _42.rootDir]), () => ( process.cwd()));
444
+ const config = _core.loadConfig.call(void 0, rootDir);
445
+ const contextDir = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _43 => _43.contextDir]), () => ( config.context_dir));
446
+ const { graph } = await _core.compile.call(void 0, { contextDir, config });
447
+ const manifest = _core.emitManifest.call(void 0, graph, config);
448
+ const host = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _44 => _44.host]), () => ( "0.0.0.0"));
449
+ const app = _expressjs.createMcpExpressApp.call(void 0, { host });
450
+ app.post("/mcp", async (req, res) => {
451
+ try {
452
+ const server = createServer(manifest, graph);
453
+ const transport = new (0, _streamableHttpjs.StreamableHTTPServerTransport)({
454
+ sessionIdGenerator: void 0
455
+ });
456
+ await server.connect(transport);
457
+ await transport.handleRequest(req, res, req.body);
458
+ res.on("close", () => {
459
+ transport.close();
460
+ server.close();
461
+ });
462
+ } catch (error) {
463
+ if (!res.headersSent) {
464
+ res.status(500).json({
465
+ jsonrpc: "2.0",
466
+ error: { code: -32603, message: "Internal server error" },
467
+ id: null
468
+ });
469
+ }
470
+ }
471
+ });
472
+ app.get("/mcp", (_req, res) => {
473
+ res.writeHead(405).end(JSON.stringify({
474
+ jsonrpc: "2.0",
475
+ error: { code: -32e3, message: "Method not allowed." },
476
+ id: null
477
+ }));
478
+ });
479
+ app.delete("/mcp", (_req, res) => {
480
+ res.writeHead(405).end(JSON.stringify({
481
+ jsonrpc: "2.0",
482
+ error: { code: -32e3, message: "Method not allowed." },
483
+ id: null
484
+ }));
485
+ });
486
+ app.get("/health", (_req, res) => {
487
+ res.json({ status: "ok", models: [...graph.models.keys()] });
488
+ });
489
+ const port = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _45 => _45.port]), () => ( 3e3));
490
+ app.listen(port, host, () => {
491
+ console.error(`ContextKit MCP server listening on http://${host}:${port}/mcp`);
492
+ console.error(`Health check: http://${host}:${port}/health`);
493
+ });
494
+ }
495
+
440
496
 
441
497
 
442
498
 
@@ -451,5 +507,5 @@ async function startServer(options) {
451
507
 
452
508
 
453
509
 
454
- exports.buildModelView = buildModelView; exports.computeModelTier = computeModelTier; exports.createServer = createServer; exports.explainModel = explainModel; exports.findGoldenQueries = findGoldenQueries; exports.findGuardrails = findGuardrails; exports.registerGlossaryResource = registerGlossaryResource; exports.registerManifestResource = registerManifestResource; exports.registerModelResource = registerModelResource; exports.registerTierResource = registerTierResource; exports.searchManifest = searchManifest; exports.startServer = startServer; exports.validateGraph = validateGraph;
510
+ exports.buildModelView = buildModelView; exports.computeModelTier = computeModelTier; exports.createServer = createServer; exports.explainModel = explainModel; exports.findGoldenQueries = findGoldenQueries; exports.findGuardrails = findGuardrails; exports.registerGlossaryResource = registerGlossaryResource; exports.registerManifestResource = registerManifestResource; exports.registerModelResource = registerModelResource; exports.registerTierResource = registerTierResource; exports.searchManifest = searchManifest; exports.startServer = startServer; exports.startServerHttp = startServerHttp; exports.validateGraph = validateGraph;
455
511
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/erickittelson/Desktop/ContextKit/packages/mcp/dist/index.cjs","../src/server.ts","../src/resources/manifest.ts","../src/resources/model.ts","../src/resources/glossary.ts","../src/resources/tier.ts","../src/tools/search.ts","../src/tools/explain.ts","../src/tools/validate.ts","../src/tools/tier.ts","../src/tools/golden-query.ts","../src/tools/guardrails.ts"],"names":["ResourceTemplate"],"mappings":"AAAA;ACAA,gEAA0B;AAC1B,oEAAqC;AAErC,wCAAkD;ADClD;AACA;AEEO,SAAS,wBAAA,CAAyB,MAAA,EAAmB,QAAA,EAA0B;AACpF,EAAA,MAAA,CAAO,QAAA;AAAA,IACL,UAAA;AAAA,IACA,oBAAA;AAAA,IACA,EAAE,WAAA,EAAa,2FAA2F,CAAA;AAAA,IAC1G,MAAA,CAAO,GAAA,EAAA,GAAA,CAAS;AAAA,MACd,QAAA,EAAU;AAAA,QACR;AAAA,UACE,GAAA,EAAK,GAAA,CAAI,IAAA;AAAA,UACT,QAAA,EAAU,kBAAA;AAAA,UACV,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,QAAA,EAAU,IAAA,EAAM,CAAC;AAAA,QACxC;AAAA,MACF;AAAA,IACF,CAAA;AAAA,EACF,CAAA;AACF;AFAA;AACA;AGvBA;AAMO,SAAS,cAAA,CAAe,IAAA,EAAc,QAAA,EAAoD;AAC/F,EAAA,MAAM,MAAA,EAAQ,QAAA,CAAS,MAAA,CAAO,IAAI,CAAA;AAClC,EAAA,GAAA,CAAI,CAAC,KAAA,EAAO,OAAO,IAAA;AAEnB,EAAA,OAAO;AAAA,IACL,KAAA;AAAA,IACA,UAAA,mBAAY,QAAA,CAAS,UAAA,CAAW,IAAI,CAAA,UAAK,MAAA;AAAA,IACzC,KAAA,mBAAO,QAAA,CAAS,KAAA,CAAM,IAAI,CAAA,UAAK,MAAA;AAAA,IAC/B,OAAA,mBAAS,QAAA,CAAS,OAAA,CAAQ,IAAI,CAAA,UAAK,MAAA;AAAA,IACnC,IAAA,mBAAM,QAAA,CAAS,KAAA,CAAM,IAAI,CAAA,UAAK;AAAA,EAChC,CAAA;AACF;AAMO,SAAS,qBAAA,CAAsB,MAAA,EAAmB,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IAAA;AACN,MAAA;AACT,MAAA;AACI,QAAA;AACP,UAAA;AACQ,YAAA;AACe,YAAA;AACvB,UAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;AACF,EAAA;AACF;AVoTuC;AACA;AWjXrB;AAWiC;AACd,EAAA;AACE,EAAA;AAEJ,EAAA;AACD,IAAA;AAEP,IAAA;AAMhB,MAAA;AAGQ,MAAA;AACE,QAAA;AACJ,UAAA;AACC,UAAA;AACT,QAAA;AACH,MAAA;AACF,IAAA;AACF,EAAA;AAEO,EAAA;AACT;AAMuC;AAC9B,EAAA;AACL,IAAA;AACA,IAAA;AACA,IAAA;AAC8B,MAAA;AAC9B,IAAA;AACsB,IAAA;AACW,MAAA;AACxB,MAAA;AACI,QAAA;AACP,UAAA;AACQ,YAAA;AACe,YAAA;AACvB,UAAA;AACF,QAAA;AACF,MAAA;AACF,IAAA;AACF,EAAA;AACF;AX0VuC;AACA;ACpY0C;AAClD,EAAA;AACrB,IAAA;AACG,IAAA;AACV,EAAA;AAGgC,EAAA;AACH,EAAA;AACG,EAAA;AACI,EAAA;AAGF,EAAA;AACC,EAAA;AACF,EAAA;AACJ,EAAA;AACE,EAAA;AACD,EAAA;AAExB,EAAA;AACT;AAUuB;AACe,EAAA;AACH,EAAA;AACL,EAAA;AAEM,EAAA;AACG,EAAA;AACT,EAAA;AAEN,EAAA;AACQ,EAAA;AAEvB,EAAA;AACT;ADqXuC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/erickittelson/Desktop/ContextKit/packages/mcp/dist/index.cjs","sourcesContent":[null,"import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport type { Manifest, ContextGraph, ContextKitConfig } from '@runcontext/core';\nimport { compile, emitManifest, loadConfig } from '@runcontext/core';\n\nimport { registerManifestResource } from './resources/manifest.js';\nimport { registerModelResource } from './resources/model.js';\nimport { registerGlossaryResource } from './resources/glossary.js';\nimport { registerTierResource } from './resources/tier.js';\n\nimport { registerSearchTool } from './tools/search.js';\nimport { registerExplainTool } from './tools/explain.js';\nimport { registerValidateTool } from './tools/validate.js';\nimport { registerTierTool } from './tools/tier.js';\nimport { registerGoldenQueryTool } from './tools/golden-query.js';\nimport { registerGuardrailsTool } from './tools/guardrails.js';\n\n/**\n * Create and configure an MCP server with all ContextKit resources and tools.\n *\n * Use this for testing or embedding — no transport is connected.\n */\nexport function createServer(manifest: Manifest, graph: ContextGraph): McpServer {\n const server = new McpServer({\n name: 'contextkit',\n version: '0.2.0',\n });\n\n // Register resources (4)\n registerManifestResource(server, manifest);\n registerModelResource(server, manifest);\n registerGlossaryResource(server, manifest);\n registerTierResource(server, manifest);\n\n // Register tools (6)\n registerSearchTool(server, manifest);\n registerExplainTool(server, manifest);\n registerValidateTool(server, graph);\n registerTierTool(server, graph);\n registerGoldenQueryTool(server, manifest);\n registerGuardrailsTool(server, manifest);\n\n return server;\n}\n\n/**\n * Compile context, create server, and connect stdio transport.\n *\n * This is the main entry point for running the MCP server as a process.\n */\nexport async function startServer(options?: {\n contextDir?: string;\n rootDir?: string;\n}): Promise<McpServer> {\n const rootDir = options?.rootDir ?? process.cwd();\n const config = loadConfig(rootDir);\n const contextDir = options?.contextDir ?? config.context_dir;\n\n const { graph } = await compile({ contextDir, config });\n const manifest = emitManifest(graph, config);\n const server = createServer(manifest, graph);\n\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\n return server;\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://manifest` resource.\n * Returns the full compiled manifest as JSON.\n */\nexport function registerManifestResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'manifest',\n 'context://manifest',\n { description: 'Full ContextKit manifest JSON (models, governance, rules, lineage, terms, owners, tiers)' },\n async (uri) => ({\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(manifest, null, 2),\n },\n ],\n }),\n );\n}\n","import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Build a merged view of a model: OSI model + governance + rules + lineage + tier.\n */\nexport function buildModelView(name: string, manifest: Manifest): Record<string, unknown> | null {\n const model = manifest.models[name];\n if (!model) return null;\n\n return {\n model,\n governance: manifest.governance[name] ?? null,\n rules: manifest.rules[name] ?? null,\n lineage: manifest.lineage[name] ?? null,\n tier: manifest.tiers[name] ?? null,\n };\n}\n\n/**\n * Register the `context://model/{name}` resource template.\n * Returns the OSI model merged with governance, rules, lineage, and tier data.\n */\nexport function registerModelResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'model',\n new ResourceTemplate('context://model/{name}', {\n list: async () => ({\n resources: Object.keys(manifest.models).map((name) => ({\n uri: `context://model/${name}`,\n name,\n description: manifest.models[name]?.description ?? `Model: ${name}`,\n })),\n }),\n }),\n { description: 'OSI semantic model merged with governance, rules, lineage, and tier' },\n async (uri, { name }) => {\n const modelName = String(name);\n const view = buildModelView(modelName, manifest);\n if (!view) {\n throw new Error(`Model '${modelName}' not found`);\n }\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(view, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://glossary` resource.\n * Returns all glossary terms as JSON.\n */\nexport function registerGlossaryResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'glossary',\n 'context://glossary',\n { description: 'All ContextKit glossary terms with definitions, synonyms, and mappings' },\n async (uri) => ({\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(manifest.terms, null, 2),\n },\n ],\n }),\n );\n}\n","import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://tier/{name}` resource template.\n * Returns the tier scorecard for a specific model.\n */\nexport function registerTierResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'tier',\n new ResourceTemplate('context://tier/{name}', {\n list: async () => ({\n resources: Object.keys(manifest.tiers).map((name) => ({\n uri: `context://tier/${name}`,\n name,\n description: `Tier scorecard for model: ${name} (${manifest.tiers[name]?.tier ?? 'unknown'})`,\n })),\n }),\n }),\n { description: 'Tier scorecard for a model (bronze/silver/gold checks and results)' },\n async (uri, { name }) => {\n const modelName = String(name);\n const tier = manifest.tiers[modelName];\n if (!tier) {\n throw new Error(`Tier data for model '${modelName}' not found`);\n }\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(tier, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest } from '@runcontext/core';\n\nexport interface SearchResult {\n type: 'model' | 'dataset' | 'field' | 'term' | 'owner';\n name: string;\n description?: string;\n model?: string;\n dataset?: string;\n}\n\n/**\n * Perform keyword search across all node types in the manifest.\n */\nexport function searchManifest(manifest: Manifest, query: string): SearchResult[] {\n const results: SearchResult[] = [];\n const q = query.toLowerCase();\n\n // Search models\n for (const [name, model] of Object.entries(manifest.models)) {\n if (\n name.toLowerCase().includes(q) ||\n model.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'model',\n name,\n description: model.description,\n });\n }\n\n // Search datasets\n for (const ds of model.datasets ?? []) {\n if (\n ds.name.toLowerCase().includes(q) ||\n ds.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'dataset',\n name: ds.name,\n description: ds.description,\n model: name,\n });\n }\n\n // Search fields\n if (ds.fields) {\n for (const field of ds.fields) {\n if (\n field.name.toLowerCase().includes(q) ||\n field.description?.toLowerCase().includes(q) ||\n field.label?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'field',\n name: field.name,\n description: field.description,\n model: name,\n dataset: ds.name,\n });\n }\n }\n }\n }\n }\n\n // Search terms\n for (const [id, term] of Object.entries(manifest.terms)) {\n if (\n id.toLowerCase().includes(q) ||\n term.definition.toLowerCase().includes(q) ||\n term.synonyms?.some((s) => s.toLowerCase().includes(q))\n ) {\n results.push({\n type: 'term',\n name: id,\n description: term.definition,\n });\n }\n }\n\n // Search owners\n for (const [id, owner] of Object.entries(manifest.owners)) {\n if (\n id.toLowerCase().includes(q) ||\n owner.display_name.toLowerCase().includes(q) ||\n owner.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'owner',\n name: id,\n description: owner.display_name,\n });\n }\n }\n\n return results;\n}\n\n/**\n * Register the `context_search` tool.\n * Keyword search across all node types (models, datasets, fields, terms, owners).\n */\nexport function registerSearchTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_search',\n 'Search across all ContextKit nodes (models, datasets, fields, terms, owners) by keyword',\n { query: z.string().describe('Keyword to search for') },\n async ({ query }) => {\n const results = searchManifest(manifest, query);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest } from '@runcontext/core';\n\nexport interface ExplainResult {\n model: Record<string, unknown>;\n governance: Record<string, unknown> | null;\n rules: Record<string, unknown> | null;\n lineage: Record<string, unknown> | null;\n tier: Record<string, unknown> | null;\n owner: Record<string, unknown> | null;\n relatedTerms: Record<string, unknown>[];\n}\n\n/**\n * Deep lookup for a model with all related governance context.\n */\nexport function explainModel(name: string, manifest: Manifest): ExplainResult | null {\n const model = manifest.models[name];\n if (!model) return null;\n\n const governance = manifest.governance[name] ?? null;\n const rules = manifest.rules[name] ?? null;\n const lineage = manifest.lineage[name] ?? null;\n const tier = manifest.tiers[name] ?? null;\n\n // Find the owner\n const ownerKey = governance?.owner;\n const owner = ownerKey ? (manifest.owners[ownerKey] ?? null) : null;\n\n // Find related glossary terms — terms whose tags overlap with model tags\n const modelTags = governance?.tags ?? [];\n const relatedTerms: Record<string, unknown>[] = [];\n for (const [, term] of Object.entries(manifest.terms)) {\n const termTags = term.tags ?? [];\n const hasOverlap = modelTags.some((t) => termTags.includes(t));\n const mapsToModel = term.maps_to?.some((m) => m === name);\n if (hasOverlap || mapsToModel) {\n relatedTerms.push(term as unknown as Record<string, unknown>);\n }\n }\n\n return {\n model: model as unknown as Record<string, unknown>,\n governance: governance as unknown as Record<string, unknown> | null,\n rules: rules as unknown as Record<string, unknown> | null,\n lineage: lineage as unknown as Record<string, unknown> | null,\n tier: tier as unknown as Record<string, unknown> | null,\n owner: owner as unknown as Record<string, unknown> | null,\n relatedTerms,\n };\n}\n\n/**\n * Register the `context_explain` tool.\n * Deep lookup with related governance for a model.\n */\nexport function registerExplainTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_explain',\n 'Deep lookup of a model with all related governance, rules, lineage, tier, owner, and glossary terms',\n { model: z.string().describe('Name of the model to explain') },\n async ({ model }) => {\n const result = explainModel(model, manifest);\n if (!result) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({ error: `Model '${model}' not found` }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { ContextGraph, Diagnostic } from '@runcontext/core';\nimport { LintEngine, ALL_RULES } from '@runcontext/core';\n\nexport interface ValidateResult {\n totalDiagnostics: number;\n errors: number;\n warnings: number;\n diagnostics: Diagnostic[];\n}\n\n/**\n * Run the full linter against the context graph.\n */\nexport function validateGraph(graph: ContextGraph): ValidateResult {\n const engine = new LintEngine();\n for (const rule of ALL_RULES) {\n engine.register(rule);\n }\n\n const diagnostics = engine.run(graph);\n const errors = diagnostics.filter((d) => d.severity === 'error').length;\n const warnings = diagnostics.filter((d) => d.severity === 'warning').length;\n\n return {\n totalDiagnostics: diagnostics.length,\n errors,\n warnings,\n diagnostics,\n };\n}\n\n/**\n * Register the `context_validate` tool.\n * Runs the linter and returns diagnostics.\n */\nexport function registerValidateTool(server: McpServer, graph: ContextGraph): void {\n server.tool(\n 'context_validate',\n 'Run ContextKit linter against the context graph and return diagnostics',\n {},\n async () => {\n const result = validateGraph(graph);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { ContextGraph, TierScore } from '@runcontext/core';\nimport { computeTier } from '@runcontext/core';\n\n/**\n * Compute the tier for a model from the context graph.\n */\nexport function computeModelTier(modelName: string, graph: ContextGraph): TierScore | null {\n if (!graph.models.has(modelName)) return null;\n return computeTier(modelName, graph);\n}\n\n/**\n * Register the `context_tier` tool.\n * Computes the tier scorecard for a specified model.\n */\nexport function registerTierTool(server: McpServer, graph: ContextGraph): void {\n server.tool(\n 'context_tier',\n 'Compute the metadata tier (none/bronze/silver/gold) for a model with detailed check results',\n { model: z.string().describe('Name of the model to tier') },\n async ({ model }) => {\n const result = computeModelTier(model, graph);\n if (!result) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({ error: `Model '${model}' not found` }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest, GoldenQuery } from '@runcontext/core';\n\nexport interface GoldenQueryMatch {\n model: string;\n query: GoldenQuery;\n score: number;\n}\n\n/**\n * Find golden queries matching a natural-language question.\n * Uses simple keyword overlap scoring.\n */\nexport function findGoldenQueries(manifest: Manifest, question: string): GoldenQueryMatch[] {\n const stopWords = new Set(['a', 'an', 'the', 'is', 'in', 'on', 'at', 'to', 'of', 'for', 'and', 'or', 'not']);\n const qWords = question.toLowerCase().split(/\\s+/).filter((w) => w.length > 0 && !stopWords.has(w));\n const matches: GoldenQueryMatch[] = [];\n\n for (const [modelName, rules] of Object.entries(manifest.rules)) {\n if (!rules.golden_queries) continue;\n\n for (const gq of rules.golden_queries) {\n const gqWords = gq.question.toLowerCase().split(/\\s+/);\n const overlap = qWords.filter((w) => gqWords.some((gw) => gw.includes(w))).length;\n if (overlap > 0) {\n matches.push({\n model: modelName,\n query: gq,\n score: overlap / Math.max(qWords.length, 1),\n });\n }\n }\n }\n\n // Sort by score descending\n matches.sort((a, b) => b.score - a.score);\n return matches;\n}\n\n/**\n * Register the `context_golden_query` tool.\n * Finds golden queries matching a given question.\n */\nexport function registerGoldenQueryTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_golden_query',\n 'Find golden SQL queries that match a natural-language question',\n { question: z.string().describe('Natural-language question to match against golden queries') },\n async ({ question }) => {\n const results = findGoldenQueries(manifest, question);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest, GuardrailFilter } from '@runcontext/core';\n\nexport interface GuardrailMatch {\n model: string;\n filter: GuardrailFilter;\n}\n\n/**\n * Find guardrail filters that apply to the given tables.\n */\nexport function findGuardrails(manifest: Manifest, tables: string[]): GuardrailMatch[] {\n const matches: GuardrailMatch[] = [];\n const tableSet = new Set(tables.map((t) => t.toLowerCase()));\n\n for (const [modelName, rules] of Object.entries(manifest.rules)) {\n if (!rules.guardrail_filters) continue;\n\n for (const gf of rules.guardrail_filters) {\n // A guardrail matches if:\n // 1. It has no tables restriction (applies globally), or\n // 2. Any of its tables match the requested tables\n const applies =\n !gf.tables ||\n gf.tables.length === 0 ||\n gf.tables.some((t) => tableSet.has(t.toLowerCase()));\n\n if (applies) {\n matches.push({\n model: modelName,\n filter: gf,\n });\n }\n }\n }\n\n return matches;\n}\n\n/**\n * Register the `context_guardrails` tool.\n * Returns guardrail filters for given tables.\n */\nexport function registerGuardrailsTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_guardrails',\n 'Return guardrail filters that apply to the specified tables',\n {\n tables: z.array(z.string()).describe('List of table names to check guardrails for'),\n },\n async ({ tables }) => {\n const results = findGuardrails(manifest, tables);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n"]}
1
+ {"version":3,"sources":["/Users/erickittelson/Desktop/ContextKit/packages/mcp/dist/index.cjs","../src/server.ts","../src/resources/manifest.ts","../src/resources/model.ts","../src/resources/glossary.ts","../src/resources/tier.ts","../src/tools/search.ts","../src/tools/explain.ts","../src/tools/validate.ts","../src/tools/tier.ts","../src/tools/golden-query.ts","../src/tools/guardrails.ts"],"names":["ResourceTemplate"],"mappings":"AAAA;ACAA,gEAA0B;AAC1B,oEAAqC;AACrC,sFAA8C;AAC9C,wEAAoC;AAEpC,wCAAkD;ADClD;AACA;AEAO,SAAS,wBAAA,CAAyB,MAAA,EAAmB,QAAA,EAA0B;AACpF,EAAA,MAAA,CAAO,QAAA;AAAA,IACL,UAAA;AAAA,IACA,oBAAA;AAAA,IACA,EAAE,WAAA,EAAa,2FAA2F,CAAA;AAAA,IAC1G,MAAA,CAAO,GAAA,EAAA,GAAA,CAAS;AAAA,MACd,QAAA,EAAU;AAAA,QACR;AAAA,UACE,GAAA,EAAK,GAAA,CAAI,IAAA;AAAA,UACT,QAAA,EAAU,kBAAA;AAAA,UACV,IAAA,EAAM,IAAA,CAAK,SAAA,CAAU,QAAA,EAAU,IAAA,EAAM,CAAC;AAAA,QACxC;AAAA,MACF;AAAA,IACF,CAAA;AAAA,EACF,CAAA;AACF;AFEA;AACA;AGzBA;AAMO,SAAS,cAAA,CAAe,IAAA,EAAc,QAAA,EAAoD;AAC/F,EAAA,MAAM,MAAA,EAAQ,QA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AUuB;AACe,EAAA;AACH,EAAA;AACL,EAAA;AAEM,EAAA;AACG,EAAA;AACT,EAAA;AAEN,EAAA;AACQ,EAAA;AAEvB,EAAA;AACT;AAQsC;AAMA,EAAA;AACH,EAAA;AACL,EAAA;AAEM,EAAA;AACG,EAAA;AAEP,EAAA;AACI,EAAA;AAGG,EAAA;AAC/B,IAAA;AAC0B,MAAA;AACN,MAAA;AACA,QAAA;AACrB,MAAA;AAC6B,MAAA;AACA,MAAA;AACR,MAAA;AACJ,QAAA;AACH,QAAA;AACd,MAAA;AACa,IAAA;AACQ,MAAA;AACC,QAAA;AACV,UAAA;AACc,UAAA;AACnB,UAAA;AACL,QAAA;AACH,MAAA;AACF,IAAA;AACD,EAAA;AAG8B,EAAA;AACD,IAAA;AACjB,MAAA;AACuB,MAAA;AAC5B,MAAA;AACJ,IAAA;AACH,EAAA;AAEiC,EAAA;AACJ,IAAA;AACjB,MAAA;AACuB,MAAA;AAC5B,MAAA;AACJ,IAAA;AACH,EAAA;AAGiC,EAAA;AACE,IAAA;AACnC,EAAA;AAE6B,EAAA;AACD,EAAA;AACb,IAAA;AACA,IAAA;AACf,EAAA;AACH;AD+VuC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/erickittelson/Desktop/ContextKit/packages/mcp/dist/index.cjs","sourcesContent":[null,"import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\nimport { createMcpExpressApp } from '@modelcontextprotocol/sdk/server/express.js';\nimport type { Manifest, ContextGraph, ContextKitConfig } from '@runcontext/core';\nimport { compile, emitManifest, loadConfig } from '@runcontext/core';\n\nimport { registerManifestResource } from './resources/manifest.js';\nimport { registerModelResource } from './resources/model.js';\nimport { registerGlossaryResource } from './resources/glossary.js';\nimport { registerTierResource } from './resources/tier.js';\n\nimport { registerSearchTool } from './tools/search.js';\nimport { registerExplainTool } from './tools/explain.js';\nimport { registerValidateTool } from './tools/validate.js';\nimport { registerTierTool } from './tools/tier.js';\nimport { registerGoldenQueryTool } from './tools/golden-query.js';\nimport { registerGuardrailsTool } from './tools/guardrails.js';\n\n/**\n * Create and configure an MCP server with all ContextKit resources and tools.\n *\n * Use this for testing or embedding — no transport is connected.\n */\nexport function createServer(manifest: Manifest, graph: ContextGraph): McpServer {\n const server = new McpServer({\n name: 'contextkit',\n version: '0.2.0',\n });\n\n // Register resources (4)\n registerManifestResource(server, manifest);\n registerModelResource(server, manifest);\n registerGlossaryResource(server, manifest);\n registerTierResource(server, manifest);\n\n // Register tools (6)\n registerSearchTool(server, manifest);\n registerExplainTool(server, manifest);\n registerValidateTool(server, graph);\n registerTierTool(server, graph);\n registerGoldenQueryTool(server, manifest);\n registerGuardrailsTool(server, manifest);\n\n return server;\n}\n\n/**\n * Compile context, create server, and connect stdio transport.\n *\n * This is the main entry point for running the MCP server as a process.\n */\nexport async function startServer(options?: {\n contextDir?: string;\n rootDir?: string;\n}): Promise<McpServer> {\n const rootDir = options?.rootDir ?? process.cwd();\n const config = loadConfig(rootDir);\n const contextDir = options?.contextDir ?? config.context_dir;\n\n const { graph } = await compile({ contextDir, config });\n const manifest = emitManifest(graph, config);\n const server = createServer(manifest, graph);\n\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\n return server;\n}\n\n/**\n * Compile context, create server, and serve over HTTP.\n *\n * Each request gets a fresh McpServer + transport (stateless mode).\n * The graph is compiled once at startup and reused for all requests.\n */\nexport async function startServerHttp(options?: {\n contextDir?: string;\n rootDir?: string;\n port?: number;\n host?: string;\n}): Promise<void> {\n const rootDir = options?.rootDir ?? process.cwd();\n const config = loadConfig(rootDir);\n const contextDir = options?.contextDir ?? config.context_dir;\n\n const { graph } = await compile({ contextDir, config });\n const manifest = emitManifest(graph, config);\n\n const host = options?.host ?? '0.0.0.0';\n const app = createMcpExpressApp({ host });\n\n // Stateless: new server + transport per POST (per MCP SDK pattern)\n app.post('/mcp', async (req, res) => {\n try {\n const server = createServer(manifest, graph);\n const transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: undefined,\n });\n await server.connect(transport);\n await transport.handleRequest(req, res, req.body);\n res.on('close', () => {\n transport.close();\n server.close();\n });\n } catch (error) {\n if (!res.headersSent) {\n res.status(500).json({\n jsonrpc: '2.0',\n error: { code: -32603, message: 'Internal server error' },\n id: null,\n });\n }\n }\n });\n\n // GET /mcp and DELETE /mcp are not supported in stateless mode\n app.get('/mcp', (_req, res) => {\n res.writeHead(405).end(JSON.stringify({\n jsonrpc: '2.0',\n error: { code: -32000, message: 'Method not allowed.' },\n id: null,\n }));\n });\n\n app.delete('/mcp', (_req, res) => {\n res.writeHead(405).end(JSON.stringify({\n jsonrpc: '2.0',\n error: { code: -32000, message: 'Method not allowed.' },\n id: null,\n }));\n });\n\n // Health check\n app.get('/health', (_req, res) => {\n res.json({ status: 'ok', models: [...graph.models.keys()] });\n });\n\n const port = options?.port ?? 3000;\n app.listen(port, host, () => {\n console.error(`ContextKit MCP server listening on http://${host}:${port}/mcp`);\n console.error(`Health check: http://${host}:${port}/health`);\n });\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://manifest` resource.\n * Returns the full compiled manifest as JSON.\n */\nexport function registerManifestResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'manifest',\n 'context://manifest',\n { description: 'Full ContextKit manifest JSON (models, governance, rules, lineage, terms, owners, tiers)' },\n async (uri) => ({\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(manifest, null, 2),\n },\n ],\n }),\n );\n}\n","import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Build a merged view of a model: OSI model + governance + rules + lineage + tier.\n */\nexport function buildModelView(name: string, manifest: Manifest): Record<string, unknown> | null {\n const model = manifest.models[name];\n if (!model) return null;\n\n return {\n model,\n governance: manifest.governance[name] ?? null,\n rules: manifest.rules[name] ?? null,\n lineage: manifest.lineage[name] ?? null,\n tier: manifest.tiers[name] ?? null,\n };\n}\n\n/**\n * Register the `context://model/{name}` resource template.\n * Returns the OSI model merged with governance, rules, lineage, and tier data.\n */\nexport function registerModelResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'model',\n new ResourceTemplate('context://model/{name}', {\n list: async () => ({\n resources: Object.keys(manifest.models).map((name) => ({\n uri: `context://model/${name}`,\n name,\n description: manifest.models[name]?.description ?? `Model: ${name}`,\n })),\n }),\n }),\n { description: 'OSI semantic model merged with governance, rules, lineage, and tier' },\n async (uri, { name }) => {\n const modelName = String(name);\n const view = buildModelView(modelName, manifest);\n if (!view) {\n throw new Error(`Model '${modelName}' not found`);\n }\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(view, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://glossary` resource.\n * Returns all glossary terms as JSON.\n */\nexport function registerGlossaryResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'glossary',\n 'context://glossary',\n { description: 'All ContextKit glossary terms with definitions, synonyms, and mappings' },\n async (uri) => ({\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(manifest.terms, null, 2),\n },\n ],\n }),\n );\n}\n","import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://tier/{name}` resource template.\n * Returns the tier scorecard for a specific model.\n */\nexport function registerTierResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'tier',\n new ResourceTemplate('context://tier/{name}', {\n list: async () => ({\n resources: Object.keys(manifest.tiers).map((name) => ({\n uri: `context://tier/${name}`,\n name,\n description: `Tier scorecard for model: ${name} (${manifest.tiers[name]?.tier ?? 'unknown'})`,\n })),\n }),\n }),\n { description: 'Tier scorecard for a model (bronze/silver/gold checks and results)' },\n async (uri, { name }) => {\n const modelName = String(name);\n const tier = manifest.tiers[modelName];\n if (!tier) {\n throw new Error(`Tier data for model '${modelName}' not found`);\n }\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(tier, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest } from '@runcontext/core';\n\nexport interface SearchResult {\n type: 'model' | 'dataset' | 'field' | 'term' | 'owner';\n name: string;\n description?: string;\n model?: string;\n dataset?: string;\n}\n\n/**\n * Perform keyword search across all node types in the manifest.\n */\nexport function searchManifest(manifest: Manifest, query: string): SearchResult[] {\n const results: SearchResult[] = [];\n const q = query.toLowerCase();\n\n // Search models\n for (const [name, model] of Object.entries(manifest.models)) {\n if (\n name.toLowerCase().includes(q) ||\n model.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'model',\n name,\n description: model.description,\n });\n }\n\n // Search datasets\n for (const ds of model.datasets ?? []) {\n if (\n ds.name.toLowerCase().includes(q) ||\n ds.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'dataset',\n name: ds.name,\n description: ds.description,\n model: name,\n });\n }\n\n // Search fields\n if (ds.fields) {\n for (const field of ds.fields) {\n if (\n field.name.toLowerCase().includes(q) ||\n field.description?.toLowerCase().includes(q) ||\n field.label?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'field',\n name: field.name,\n description: field.description,\n model: name,\n dataset: ds.name,\n });\n }\n }\n }\n }\n }\n\n // Search terms\n for (const [id, term] of Object.entries(manifest.terms)) {\n if (\n id.toLowerCase().includes(q) ||\n term.definition.toLowerCase().includes(q) ||\n term.synonyms?.some((s) => s.toLowerCase().includes(q))\n ) {\n results.push({\n type: 'term',\n name: id,\n description: term.definition,\n });\n }\n }\n\n // Search owners\n for (const [id, owner] of Object.entries(manifest.owners)) {\n if (\n id.toLowerCase().includes(q) ||\n owner.display_name.toLowerCase().includes(q) ||\n owner.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'owner',\n name: id,\n description: owner.display_name,\n });\n }\n }\n\n return results;\n}\n\n/**\n * Register the `context_search` tool.\n * Keyword search across all node types (models, datasets, fields, terms, owners).\n */\nexport function registerSearchTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_search',\n 'Search across all ContextKit nodes (models, datasets, fields, terms, owners) by keyword',\n { query: z.string().describe('Keyword to search for') },\n async ({ query }) => {\n const results = searchManifest(manifest, query);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest } from '@runcontext/core';\n\nexport interface ExplainResult {\n model: Record<string, unknown>;\n governance: Record<string, unknown> | null;\n rules: Record<string, unknown> | null;\n lineage: Record<string, unknown> | null;\n tier: Record<string, unknown> | null;\n owner: Record<string, unknown> | null;\n relatedTerms: Record<string, unknown>[];\n}\n\n/**\n * Deep lookup for a model with all related governance context.\n */\nexport function explainModel(name: string, manifest: Manifest): ExplainResult | null {\n const model = manifest.models[name];\n if (!model) return null;\n\n const governance = manifest.governance[name] ?? null;\n const rules = manifest.rules[name] ?? null;\n const lineage = manifest.lineage[name] ?? null;\n const tier = manifest.tiers[name] ?? null;\n\n // Find the owner\n const ownerKey = governance?.owner;\n const owner = ownerKey ? (manifest.owners[ownerKey] ?? null) : null;\n\n // Find related glossary terms — terms whose tags overlap with model tags\n const modelTags = governance?.tags ?? [];\n const relatedTerms: Record<string, unknown>[] = [];\n for (const [, term] of Object.entries(manifest.terms)) {\n const termTags = term.tags ?? [];\n const hasOverlap = modelTags.some((t) => termTags.includes(t));\n const mapsToModel = term.maps_to?.some((m) => m === name);\n if (hasOverlap || mapsToModel) {\n relatedTerms.push(term as unknown as Record<string, unknown>);\n }\n }\n\n return {\n model: model as unknown as Record<string, unknown>,\n governance: governance as unknown as Record<string, unknown> | null,\n rules: rules as unknown as Record<string, unknown> | null,\n lineage: lineage as unknown as Record<string, unknown> | null,\n tier: tier as unknown as Record<string, unknown> | null,\n owner: owner as unknown as Record<string, unknown> | null,\n relatedTerms,\n };\n}\n\n/**\n * Register the `context_explain` tool.\n * Deep lookup with related governance for a model.\n */\nexport function registerExplainTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_explain',\n 'Deep lookup of a model with all related governance, rules, lineage, tier, owner, and glossary terms',\n { model: z.string().describe('Name of the model to explain') },\n async ({ model }) => {\n const result = explainModel(model, manifest);\n if (!result) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({ error: `Model '${model}' not found` }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { ContextGraph, Diagnostic } from '@runcontext/core';\nimport { LintEngine, ALL_RULES } from '@runcontext/core';\n\nexport interface ValidateResult {\n totalDiagnostics: number;\n errors: number;\n warnings: number;\n diagnostics: Diagnostic[];\n}\n\n/**\n * Run the full linter against the context graph.\n */\nexport function validateGraph(graph: ContextGraph): ValidateResult {\n const engine = new LintEngine();\n for (const rule of ALL_RULES) {\n engine.register(rule);\n }\n\n const diagnostics = engine.run(graph);\n const errors = diagnostics.filter((d) => d.severity === 'error').length;\n const warnings = diagnostics.filter((d) => d.severity === 'warning').length;\n\n return {\n totalDiagnostics: diagnostics.length,\n errors,\n warnings,\n diagnostics,\n };\n}\n\n/**\n * Register the `context_validate` tool.\n * Runs the linter and returns diagnostics.\n */\nexport function registerValidateTool(server: McpServer, graph: ContextGraph): void {\n server.tool(\n 'context_validate',\n 'Run ContextKit linter against the context graph and return diagnostics',\n {},\n async () => {\n const result = validateGraph(graph);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { ContextGraph, TierScore } from '@runcontext/core';\nimport { computeTier } from '@runcontext/core';\n\n/**\n * Compute the tier for a model from the context graph.\n */\nexport function computeModelTier(modelName: string, graph: ContextGraph): TierScore | null {\n if (!graph.models.has(modelName)) return null;\n return computeTier(modelName, graph);\n}\n\n/**\n * Register the `context_tier` tool.\n * Computes the tier scorecard for a specified model.\n */\nexport function registerTierTool(server: McpServer, graph: ContextGraph): void {\n server.tool(\n 'context_tier',\n 'Compute the metadata tier (none/bronze/silver/gold) for a model with detailed check results',\n { model: z.string().describe('Name of the model to tier') },\n async ({ model }) => {\n const result = computeModelTier(model, graph);\n if (!result) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({ error: `Model '${model}' not found` }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest, GoldenQuery } from '@runcontext/core';\n\nexport interface GoldenQueryMatch {\n model: string;\n query: GoldenQuery;\n score: number;\n}\n\n/**\n * Find golden queries matching a natural-language question.\n * Uses simple keyword overlap scoring.\n */\nexport function findGoldenQueries(manifest: Manifest, question: string): GoldenQueryMatch[] {\n const stopWords = new Set(['a', 'an', 'the', 'is', 'in', 'on', 'at', 'to', 'of', 'for', 'and', 'or', 'not']);\n const qWords = question.toLowerCase().split(/\\s+/).filter((w) => w.length > 0 && !stopWords.has(w));\n const matches: GoldenQueryMatch[] = [];\n\n for (const [modelName, rules] of Object.entries(manifest.rules)) {\n if (!rules.golden_queries) continue;\n\n for (const gq of rules.golden_queries) {\n const gqWords = gq.question.toLowerCase().split(/\\s+/);\n const overlap = qWords.filter((w) => gqWords.some((gw) => gw.includes(w))).length;\n if (overlap > 0) {\n matches.push({\n model: modelName,\n query: gq,\n score: overlap / Math.max(qWords.length, 1),\n });\n }\n }\n }\n\n // Sort by score descending\n matches.sort((a, b) => b.score - a.score);\n return matches;\n}\n\n/**\n * Register the `context_golden_query` tool.\n * Finds golden queries matching a given question.\n */\nexport function registerGoldenQueryTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_golden_query',\n 'Find golden SQL queries that match a natural-language question',\n { question: z.string().describe('Natural-language question to match against golden queries') },\n async ({ question }) => {\n const results = findGoldenQueries(manifest, question);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest, GuardrailFilter } from '@runcontext/core';\n\nexport interface GuardrailMatch {\n model: string;\n filter: GuardrailFilter;\n}\n\n/**\n * Find guardrail filters that apply to the given tables.\n */\nexport function findGuardrails(manifest: Manifest, tables: string[]): GuardrailMatch[] {\n const matches: GuardrailMatch[] = [];\n const tableSet = new Set(tables.map((t) => t.toLowerCase()));\n\n for (const [modelName, rules] of Object.entries(manifest.rules)) {\n if (!rules.guardrail_filters) continue;\n\n for (const gf of rules.guardrail_filters) {\n // A guardrail matches if:\n // 1. It has no tables restriction (applies globally), or\n // 2. Any of its tables match the requested tables\n const applies =\n !gf.tables ||\n gf.tables.length === 0 ||\n gf.tables.some((t) => tableSet.has(t.toLowerCase()));\n\n if (applies) {\n matches.push({\n model: modelName,\n filter: gf,\n });\n }\n }\n }\n\n return matches;\n}\n\n/**\n * Register the `context_guardrails` tool.\n * Returns guardrail filters for given tables.\n */\nexport function registerGuardrailsTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_guardrails',\n 'Return guardrail filters that apply to the specified tables',\n {\n tables: z.array(z.string()).describe('List of table names to check guardrails for'),\n },\n async ({ tables }) => {\n const results = findGuardrails(manifest, tables);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -16,6 +16,18 @@ declare function startServer(options?: {
16
16
  contextDir?: string;
17
17
  rootDir?: string;
18
18
  }): Promise<McpServer>;
19
+ /**
20
+ * Compile context, create server, and serve over HTTP.
21
+ *
22
+ * Each request gets a fresh McpServer + transport (stateless mode).
23
+ * The graph is compiled once at startup and reused for all requests.
24
+ */
25
+ declare function startServerHttp(options?: {
26
+ contextDir?: string;
27
+ rootDir?: string;
28
+ port?: number;
29
+ host?: string;
30
+ }): Promise<void>;
19
31
 
20
32
  /**
21
33
  * Register the `context://manifest` resource.
@@ -107,4 +119,4 @@ interface GuardrailMatch {
107
119
  */
108
120
  declare function findGuardrails(manifest: Manifest, tables: string[]): GuardrailMatch[];
109
121
 
110
- export { type ExplainResult, type GoldenQueryMatch, type GuardrailMatch, type SearchResult, type ValidateResult, buildModelView, computeModelTier, createServer, explainModel, findGoldenQueries, findGuardrails, registerGlossaryResource, registerManifestResource, registerModelResource, registerTierResource, searchManifest, startServer, validateGraph };
122
+ export { type ExplainResult, type GoldenQueryMatch, type GuardrailMatch, type SearchResult, type ValidateResult, buildModelView, computeModelTier, createServer, explainModel, findGoldenQueries, findGuardrails, registerGlossaryResource, registerManifestResource, registerModelResource, registerTierResource, searchManifest, startServer, startServerHttp, validateGraph };
package/dist/index.d.ts CHANGED
@@ -16,6 +16,18 @@ declare function startServer(options?: {
16
16
  contextDir?: string;
17
17
  rootDir?: string;
18
18
  }): Promise<McpServer>;
19
+ /**
20
+ * Compile context, create server, and serve over HTTP.
21
+ *
22
+ * Each request gets a fresh McpServer + transport (stateless mode).
23
+ * The graph is compiled once at startup and reused for all requests.
24
+ */
25
+ declare function startServerHttp(options?: {
26
+ contextDir?: string;
27
+ rootDir?: string;
28
+ port?: number;
29
+ host?: string;
30
+ }): Promise<void>;
19
31
 
20
32
  /**
21
33
  * Register the `context://manifest` resource.
@@ -107,4 +119,4 @@ interface GuardrailMatch {
107
119
  */
108
120
  declare function findGuardrails(manifest: Manifest, tables: string[]): GuardrailMatch[];
109
121
 
110
- export { type ExplainResult, type GoldenQueryMatch, type GuardrailMatch, type SearchResult, type ValidateResult, buildModelView, computeModelTier, createServer, explainModel, findGoldenQueries, findGuardrails, registerGlossaryResource, registerManifestResource, registerModelResource, registerTierResource, searchManifest, startServer, validateGraph };
122
+ export { type ExplainResult, type GoldenQueryMatch, type GuardrailMatch, type SearchResult, type ValidateResult, buildModelView, computeModelTier, createServer, explainModel, findGoldenQueries, findGuardrails, registerGlossaryResource, registerManifestResource, registerModelResource, registerTierResource, searchManifest, startServer, startServerHttp, validateGraph };
package/dist/index.mjs CHANGED
@@ -1,6 +1,8 @@
1
1
  // src/server.ts
2
2
  import { McpServer as McpServer3 } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
5
+ import { createMcpExpressApp } from "@modelcontextprotocol/sdk/server/express.js";
4
6
  import { compile, emitManifest, loadConfig } from "@runcontext/core";
5
7
 
6
8
  // src/resources/manifest.ts
@@ -437,6 +439,59 @@ async function startServer(options) {
437
439
  await server.connect(transport);
438
440
  return server;
439
441
  }
442
+ async function startServerHttp(options) {
443
+ const rootDir = options?.rootDir ?? process.cwd();
444
+ const config = loadConfig(rootDir);
445
+ const contextDir = options?.contextDir ?? config.context_dir;
446
+ const { graph } = await compile({ contextDir, config });
447
+ const manifest = emitManifest(graph, config);
448
+ const host = options?.host ?? "0.0.0.0";
449
+ const app = createMcpExpressApp({ host });
450
+ app.post("/mcp", async (req, res) => {
451
+ try {
452
+ const server = createServer(manifest, graph);
453
+ const transport = new StreamableHTTPServerTransport({
454
+ sessionIdGenerator: void 0
455
+ });
456
+ await server.connect(transport);
457
+ await transport.handleRequest(req, res, req.body);
458
+ res.on("close", () => {
459
+ transport.close();
460
+ server.close();
461
+ });
462
+ } catch (error) {
463
+ if (!res.headersSent) {
464
+ res.status(500).json({
465
+ jsonrpc: "2.0",
466
+ error: { code: -32603, message: "Internal server error" },
467
+ id: null
468
+ });
469
+ }
470
+ }
471
+ });
472
+ app.get("/mcp", (_req, res) => {
473
+ res.writeHead(405).end(JSON.stringify({
474
+ jsonrpc: "2.0",
475
+ error: { code: -32e3, message: "Method not allowed." },
476
+ id: null
477
+ }));
478
+ });
479
+ app.delete("/mcp", (_req, res) => {
480
+ res.writeHead(405).end(JSON.stringify({
481
+ jsonrpc: "2.0",
482
+ error: { code: -32e3, message: "Method not allowed." },
483
+ id: null
484
+ }));
485
+ });
486
+ app.get("/health", (_req, res) => {
487
+ res.json({ status: "ok", models: [...graph.models.keys()] });
488
+ });
489
+ const port = options?.port ?? 3e3;
490
+ app.listen(port, host, () => {
491
+ console.error(`ContextKit MCP server listening on http://${host}:${port}/mcp`);
492
+ console.error(`Health check: http://${host}:${port}/health`);
493
+ });
494
+ }
440
495
  export {
441
496
  buildModelView,
442
497
  computeModelTier,
@@ -450,6 +505,7 @@ export {
450
505
  registerTierResource,
451
506
  searchManifest,
452
507
  startServer,
508
+ startServerHttp,
453
509
  validateGraph
454
510
  };
455
511
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/server.ts","../src/resources/manifest.ts","../src/resources/model.ts","../src/resources/glossary.ts","../src/resources/tier.ts","../src/tools/search.ts","../src/tools/explain.ts","../src/tools/validate.ts","../src/tools/tier.ts","../src/tools/golden-query.ts","../src/tools/guardrails.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport type { Manifest, ContextGraph, ContextKitConfig } from '@runcontext/core';\nimport { compile, emitManifest, loadConfig } from '@runcontext/core';\n\nimport { registerManifestResource } from './resources/manifest.js';\nimport { registerModelResource } from './resources/model.js';\nimport { registerGlossaryResource } from './resources/glossary.js';\nimport { registerTierResource } from './resources/tier.js';\n\nimport { registerSearchTool } from './tools/search.js';\nimport { registerExplainTool } from './tools/explain.js';\nimport { registerValidateTool } from './tools/validate.js';\nimport { registerTierTool } from './tools/tier.js';\nimport { registerGoldenQueryTool } from './tools/golden-query.js';\nimport { registerGuardrailsTool } from './tools/guardrails.js';\n\n/**\n * Create and configure an MCP server with all ContextKit resources and tools.\n *\n * Use this for testing or embedding — no transport is connected.\n */\nexport function createServer(manifest: Manifest, graph: ContextGraph): McpServer {\n const server = new McpServer({\n name: 'contextkit',\n version: '0.2.0',\n });\n\n // Register resources (4)\n registerManifestResource(server, manifest);\n registerModelResource(server, manifest);\n registerGlossaryResource(server, manifest);\n registerTierResource(server, manifest);\n\n // Register tools (6)\n registerSearchTool(server, manifest);\n registerExplainTool(server, manifest);\n registerValidateTool(server, graph);\n registerTierTool(server, graph);\n registerGoldenQueryTool(server, manifest);\n registerGuardrailsTool(server, manifest);\n\n return server;\n}\n\n/**\n * Compile context, create server, and connect stdio transport.\n *\n * This is the main entry point for running the MCP server as a process.\n */\nexport async function startServer(options?: {\n contextDir?: string;\n rootDir?: string;\n}): Promise<McpServer> {\n const rootDir = options?.rootDir ?? process.cwd();\n const config = loadConfig(rootDir);\n const contextDir = options?.contextDir ?? config.context_dir;\n\n const { graph } = await compile({ contextDir, config });\n const manifest = emitManifest(graph, config);\n const server = createServer(manifest, graph);\n\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\n return server;\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://manifest` resource.\n * Returns the full compiled manifest as JSON.\n */\nexport function registerManifestResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'manifest',\n 'context://manifest',\n { description: 'Full ContextKit manifest JSON (models, governance, rules, lineage, terms, owners, tiers)' },\n async (uri) => ({\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(manifest, null, 2),\n },\n ],\n }),\n );\n}\n","import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Build a merged view of a model: OSI model + governance + rules + lineage + tier.\n */\nexport function buildModelView(name: string, manifest: Manifest): Record<string, unknown> | null {\n const model = manifest.models[name];\n if (!model) return null;\n\n return {\n model,\n governance: manifest.governance[name] ?? null,\n rules: manifest.rules[name] ?? null,\n lineage: manifest.lineage[name] ?? null,\n tier: manifest.tiers[name] ?? null,\n };\n}\n\n/**\n * Register the `context://model/{name}` resource template.\n * Returns the OSI model merged with governance, rules, lineage, and tier data.\n */\nexport function registerModelResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'model',\n new ResourceTemplate('context://model/{name}', {\n list: async () => ({\n resources: Object.keys(manifest.models).map((name) => ({\n uri: `context://model/${name}`,\n name,\n description: manifest.models[name]?.description ?? `Model: ${name}`,\n })),\n }),\n }),\n { description: 'OSI semantic model merged with governance, rules, lineage, and tier' },\n async (uri, { name }) => {\n const modelName = String(name);\n const view = buildModelView(modelName, manifest);\n if (!view) {\n throw new Error(`Model '${modelName}' not found`);\n }\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(view, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://glossary` resource.\n * Returns all glossary terms as JSON.\n */\nexport function registerGlossaryResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'glossary',\n 'context://glossary',\n { description: 'All ContextKit glossary terms with definitions, synonyms, and mappings' },\n async (uri) => ({\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(manifest.terms, null, 2),\n },\n ],\n }),\n );\n}\n","import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://tier/{name}` resource template.\n * Returns the tier scorecard for a specific model.\n */\nexport function registerTierResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'tier',\n new ResourceTemplate('context://tier/{name}', {\n list: async () => ({\n resources: Object.keys(manifest.tiers).map((name) => ({\n uri: `context://tier/${name}`,\n name,\n description: `Tier scorecard for model: ${name} (${manifest.tiers[name]?.tier ?? 'unknown'})`,\n })),\n }),\n }),\n { description: 'Tier scorecard for a model (bronze/silver/gold checks and results)' },\n async (uri, { name }) => {\n const modelName = String(name);\n const tier = manifest.tiers[modelName];\n if (!tier) {\n throw new Error(`Tier data for model '${modelName}' not found`);\n }\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(tier, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest } from '@runcontext/core';\n\nexport interface SearchResult {\n type: 'model' | 'dataset' | 'field' | 'term' | 'owner';\n name: string;\n description?: string;\n model?: string;\n dataset?: string;\n}\n\n/**\n * Perform keyword search across all node types in the manifest.\n */\nexport function searchManifest(manifest: Manifest, query: string): SearchResult[] {\n const results: SearchResult[] = [];\n const q = query.toLowerCase();\n\n // Search models\n for (const [name, model] of Object.entries(manifest.models)) {\n if (\n name.toLowerCase().includes(q) ||\n model.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'model',\n name,\n description: model.description,\n });\n }\n\n // Search datasets\n for (const ds of model.datasets ?? []) {\n if (\n ds.name.toLowerCase().includes(q) ||\n ds.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'dataset',\n name: ds.name,\n description: ds.description,\n model: name,\n });\n }\n\n // Search fields\n if (ds.fields) {\n for (const field of ds.fields) {\n if (\n field.name.toLowerCase().includes(q) ||\n field.description?.toLowerCase().includes(q) ||\n field.label?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'field',\n name: field.name,\n description: field.description,\n model: name,\n dataset: ds.name,\n });\n }\n }\n }\n }\n }\n\n // Search terms\n for (const [id, term] of Object.entries(manifest.terms)) {\n if (\n id.toLowerCase().includes(q) ||\n term.definition.toLowerCase().includes(q) ||\n term.synonyms?.some((s) => s.toLowerCase().includes(q))\n ) {\n results.push({\n type: 'term',\n name: id,\n description: term.definition,\n });\n }\n }\n\n // Search owners\n for (const [id, owner] of Object.entries(manifest.owners)) {\n if (\n id.toLowerCase().includes(q) ||\n owner.display_name.toLowerCase().includes(q) ||\n owner.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'owner',\n name: id,\n description: owner.display_name,\n });\n }\n }\n\n return results;\n}\n\n/**\n * Register the `context_search` tool.\n * Keyword search across all node types (models, datasets, fields, terms, owners).\n */\nexport function registerSearchTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_search',\n 'Search across all ContextKit nodes (models, datasets, fields, terms, owners) by keyword',\n { query: z.string().describe('Keyword to search for') },\n async ({ query }) => {\n const results = searchManifest(manifest, query);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest } from '@runcontext/core';\n\nexport interface ExplainResult {\n model: Record<string, unknown>;\n governance: Record<string, unknown> | null;\n rules: Record<string, unknown> | null;\n lineage: Record<string, unknown> | null;\n tier: Record<string, unknown> | null;\n owner: Record<string, unknown> | null;\n relatedTerms: Record<string, unknown>[];\n}\n\n/**\n * Deep lookup for a model with all related governance context.\n */\nexport function explainModel(name: string, manifest: Manifest): ExplainResult | null {\n const model = manifest.models[name];\n if (!model) return null;\n\n const governance = manifest.governance[name] ?? null;\n const rules = manifest.rules[name] ?? null;\n const lineage = manifest.lineage[name] ?? null;\n const tier = manifest.tiers[name] ?? null;\n\n // Find the owner\n const ownerKey = governance?.owner;\n const owner = ownerKey ? (manifest.owners[ownerKey] ?? null) : null;\n\n // Find related glossary terms — terms whose tags overlap with model tags\n const modelTags = governance?.tags ?? [];\n const relatedTerms: Record<string, unknown>[] = [];\n for (const [, term] of Object.entries(manifest.terms)) {\n const termTags = term.tags ?? [];\n const hasOverlap = modelTags.some((t) => termTags.includes(t));\n const mapsToModel = term.maps_to?.some((m) => m === name);\n if (hasOverlap || mapsToModel) {\n relatedTerms.push(term as unknown as Record<string, unknown>);\n }\n }\n\n return {\n model: model as unknown as Record<string, unknown>,\n governance: governance as unknown as Record<string, unknown> | null,\n rules: rules as unknown as Record<string, unknown> | null,\n lineage: lineage as unknown as Record<string, unknown> | null,\n tier: tier as unknown as Record<string, unknown> | null,\n owner: owner as unknown as Record<string, unknown> | null,\n relatedTerms,\n };\n}\n\n/**\n * Register the `context_explain` tool.\n * Deep lookup with related governance for a model.\n */\nexport function registerExplainTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_explain',\n 'Deep lookup of a model with all related governance, rules, lineage, tier, owner, and glossary terms',\n { model: z.string().describe('Name of the model to explain') },\n async ({ model }) => {\n const result = explainModel(model, manifest);\n if (!result) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({ error: `Model '${model}' not found` }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { ContextGraph, Diagnostic } from '@runcontext/core';\nimport { LintEngine, ALL_RULES } from '@runcontext/core';\n\nexport interface ValidateResult {\n totalDiagnostics: number;\n errors: number;\n warnings: number;\n diagnostics: Diagnostic[];\n}\n\n/**\n * Run the full linter against the context graph.\n */\nexport function validateGraph(graph: ContextGraph): ValidateResult {\n const engine = new LintEngine();\n for (const rule of ALL_RULES) {\n engine.register(rule);\n }\n\n const diagnostics = engine.run(graph);\n const errors = diagnostics.filter((d) => d.severity === 'error').length;\n const warnings = diagnostics.filter((d) => d.severity === 'warning').length;\n\n return {\n totalDiagnostics: diagnostics.length,\n errors,\n warnings,\n diagnostics,\n };\n}\n\n/**\n * Register the `context_validate` tool.\n * Runs the linter and returns diagnostics.\n */\nexport function registerValidateTool(server: McpServer, graph: ContextGraph): void {\n server.tool(\n 'context_validate',\n 'Run ContextKit linter against the context graph and return diagnostics',\n {},\n async () => {\n const result = validateGraph(graph);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { ContextGraph, TierScore } from '@runcontext/core';\nimport { computeTier } from '@runcontext/core';\n\n/**\n * Compute the tier for a model from the context graph.\n */\nexport function computeModelTier(modelName: string, graph: ContextGraph): TierScore | null {\n if (!graph.models.has(modelName)) return null;\n return computeTier(modelName, graph);\n}\n\n/**\n * Register the `context_tier` tool.\n * Computes the tier scorecard for a specified model.\n */\nexport function registerTierTool(server: McpServer, graph: ContextGraph): void {\n server.tool(\n 'context_tier',\n 'Compute the metadata tier (none/bronze/silver/gold) for a model with detailed check results',\n { model: z.string().describe('Name of the model to tier') },\n async ({ model }) => {\n const result = computeModelTier(model, graph);\n if (!result) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({ error: `Model '${model}' not found` }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest, GoldenQuery } from '@runcontext/core';\n\nexport interface GoldenQueryMatch {\n model: string;\n query: GoldenQuery;\n score: number;\n}\n\n/**\n * Find golden queries matching a natural-language question.\n * Uses simple keyword overlap scoring.\n */\nexport function findGoldenQueries(manifest: Manifest, question: string): GoldenQueryMatch[] {\n const stopWords = new Set(['a', 'an', 'the', 'is', 'in', 'on', 'at', 'to', 'of', 'for', 'and', 'or', 'not']);\n const qWords = question.toLowerCase().split(/\\s+/).filter((w) => w.length > 0 && !stopWords.has(w));\n const matches: GoldenQueryMatch[] = [];\n\n for (const [modelName, rules] of Object.entries(manifest.rules)) {\n if (!rules.golden_queries) continue;\n\n for (const gq of rules.golden_queries) {\n const gqWords = gq.question.toLowerCase().split(/\\s+/);\n const overlap = qWords.filter((w) => gqWords.some((gw) => gw.includes(w))).length;\n if (overlap > 0) {\n matches.push({\n model: modelName,\n query: gq,\n score: overlap / Math.max(qWords.length, 1),\n });\n }\n }\n }\n\n // Sort by score descending\n matches.sort((a, b) => b.score - a.score);\n return matches;\n}\n\n/**\n * Register the `context_golden_query` tool.\n * Finds golden queries matching a given question.\n */\nexport function registerGoldenQueryTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_golden_query',\n 'Find golden SQL queries that match a natural-language question',\n { question: z.string().describe('Natural-language question to match against golden queries') },\n async ({ question }) => {\n const results = findGoldenQueries(manifest, question);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest, GuardrailFilter } from '@runcontext/core';\n\nexport interface GuardrailMatch {\n model: string;\n filter: GuardrailFilter;\n}\n\n/**\n * Find guardrail filters that apply to the given tables.\n */\nexport function findGuardrails(manifest: Manifest, tables: string[]): GuardrailMatch[] {\n const matches: GuardrailMatch[] = [];\n const tableSet = new Set(tables.map((t) => t.toLowerCase()));\n\n for (const [modelName, rules] of Object.entries(manifest.rules)) {\n if (!rules.guardrail_filters) continue;\n\n for (const gf of rules.guardrail_filters) {\n // A guardrail matches if:\n // 1. It has no tables restriction (applies globally), or\n // 2. Any of its tables match the requested tables\n const applies =\n !gf.tables ||\n gf.tables.length === 0 ||\n gf.tables.some((t) => tableSet.has(t.toLowerCase()));\n\n if (applies) {\n matches.push({\n model: modelName,\n filter: gf,\n });\n }\n }\n }\n\n return matches;\n}\n\n/**\n * Register the `context_guardrails` tool.\n * Returns guardrail filters for given tables.\n */\nexport function registerGuardrailsTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_guardrails',\n 'Return guardrail filters that apply to the specified tables',\n {\n tables: z.array(z.string()).describe('List of table names to check guardrails for'),\n },\n async ({ tables }) => {\n const results = findGuardrails(manifest, tables);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n"],"mappings":";AAAA,SAAS,aAAAA,kBAAiB;AAC1B,SAAS,4BAA4B;AAErC,SAAS,SAAS,cAAc,kBAAkB;;;ACI3C,SAAS,yBAAyB,QAAmB,UAA0B;AACpF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,EAAE,aAAa,2FAA2F;AAAA,IAC1G,OAAO,SAAS;AAAA,MACd,UAAU;AAAA,QACR;AAAA,UACE,KAAK,IAAI;AAAA,UACT,UAAU;AAAA,UACV,MAAM,KAAK,UAAU,UAAU,MAAM,CAAC;AAAA,QACxC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;;;ACtBA,SAAoB,wBAAwB;AAMrC,SAAS,eAAe,MAAc,UAAoD;AAC/F,QAAM,QAAQ,SAAS,OAAO,IAAI;AAClC,MAAI,CAAC,MAAO,QAAO;AAEnB,SAAO;AAAA,IACL;AAAA,IACA,YAAY,SAAS,WAAW,IAAI,KAAK;AAAA,IACzC,OAAO,SAAS,MAAM,IAAI,KAAK;AAAA,IAC/B,SAAS,SAAS,QAAQ,IAAI,KAAK;AAAA,IACnC,MAAM,SAAS,MAAM,IAAI,KAAK;AAAA,EAChC;AACF;AAMO,SAAS,sBAAsB,QAAmB,UAA0B;AACjF,SAAO;AAAA,IACL;AAAA,IACA,IAAI,iBAAiB,0BAA0B;AA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CAAC,EAAE,SAAS,6CAA6C;AAAA,IACpF;AAAA,IACA,OAAO,EAAE,OAAO,MAAM;AACpB,YAAM,UAAU,eAAe,UAAU,MAAM;AAC/C,aAAO;AAAA,QACL,SAAS;AAAA,UACP;AAAA,YACE,MAAM;AAAA,YACN,MAAM,KAAK,UAAU,SAAS,MAAM,CAAC;AAAA,UACvC;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;;;AVzCO,SAAS,aAAa,UAAoB,OAAgC;AAC/E,QAAM,SAAS,IAAIC,WAAU;AAAA,IAC3B,MAAM;AAAA,IACN,SAAS;AAAA,EACX,CAAC;AAGD,2BAAyB,QAAQ,QAAQ;AACzC,wBAAsB,QAAQ,QAAQ;AACtC,2BAAyB,QAAQ,QAAQ;AACzC,uBAAqB,QAAQ,QAAQ;AAGrC,qBAAmB,QAAQ,QAAQ;AACnC,sBAAoB,QAAQ,QAAQ;AACpC,uBAAqB,QAAQ,KAAK;AAClC,mBAAiB,QAAQ,KAAK;AAC9B,0BAAwB,QAAQ,QAAQ;AACxC,yBAAuB,QAAQ,QAAQ;AAEvC,SAAO;AACT;AAOA,eAAsB,YAAY,SAGX;AACrB,QAAM,UAAU,SAAS,WAAW,QAAQ,IAAI;AAChD,QAAM,SAAS,WAAW,OAAO;AACjC,QAAM,aAAa,SAAS,cAAc,OAAO;AAEjD,QAAM,EAAE,MAAM,IAAI,MAAM,QAAQ,EAAE,YAAY,OAAO,CAAC;AACtD,QAAM,WAAW,aAAa,OAAO,MAAM;AAC3C,QAAM,SAAS,aAAa,UAAU,KAAK;AAE3C,QAAM,YAAY,IAAI,qBAAqB;AAC3C,QAAM,OAAO,QAAQ,SAAS;AAE9B,SAAO;AACT;","names":["McpServer","ResourceTemplate","z","z","z","z","McpServer"]}
1
+ {"version":3,"sources":["../src/server.ts","../src/resources/manifest.ts","../src/resources/model.ts","../src/resources/glossary.ts","../src/resources/tier.ts","../src/tools/search.ts","../src/tools/explain.ts","../src/tools/validate.ts","../src/tools/tier.ts","../src/tools/golden-query.ts","../src/tools/guardrails.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';\nimport { createMcpExpressApp } from '@modelcontextprotocol/sdk/server/express.js';\nimport type { Manifest, ContextGraph, ContextKitConfig } from '@runcontext/core';\nimport { compile, emitManifest, loadConfig } from '@runcontext/core';\n\nimport { registerManifestResource } from './resources/manifest.js';\nimport { registerModelResource } from './resources/model.js';\nimport { registerGlossaryResource } from './resources/glossary.js';\nimport { registerTierResource } from './resources/tier.js';\n\nimport { registerSearchTool } from './tools/search.js';\nimport { registerExplainTool } from './tools/explain.js';\nimport { registerValidateTool } from './tools/validate.js';\nimport { registerTierTool } from './tools/tier.js';\nimport { registerGoldenQueryTool } from './tools/golden-query.js';\nimport { registerGuardrailsTool } from './tools/guardrails.js';\n\n/**\n * Create and configure an MCP server with all ContextKit resources and tools.\n *\n * Use this for testing or embedding — no transport is connected.\n */\nexport function createServer(manifest: Manifest, graph: ContextGraph): McpServer {\n const server = new McpServer({\n name: 'contextkit',\n version: '0.2.0',\n });\n\n // Register resources (4)\n registerManifestResource(server, manifest);\n registerModelResource(server, manifest);\n registerGlossaryResource(server, manifest);\n registerTierResource(server, manifest);\n\n // Register tools (6)\n registerSearchTool(server, manifest);\n registerExplainTool(server, manifest);\n registerValidateTool(server, graph);\n registerTierTool(server, graph);\n registerGoldenQueryTool(server, manifest);\n registerGuardrailsTool(server, manifest);\n\n return server;\n}\n\n/**\n * Compile context, create server, and connect stdio transport.\n *\n * This is the main entry point for running the MCP server as a process.\n */\nexport async function startServer(options?: {\n contextDir?: string;\n rootDir?: string;\n}): Promise<McpServer> {\n const rootDir = options?.rootDir ?? process.cwd();\n const config = loadConfig(rootDir);\n const contextDir = options?.contextDir ?? config.context_dir;\n\n const { graph } = await compile({ contextDir, config });\n const manifest = emitManifest(graph, config);\n const server = createServer(manifest, graph);\n\n const transport = new StdioServerTransport();\n await server.connect(transport);\n\n return server;\n}\n\n/**\n * Compile context, create server, and serve over HTTP.\n *\n * Each request gets a fresh McpServer + transport (stateless mode).\n * The graph is compiled once at startup and reused for all requests.\n */\nexport async function startServerHttp(options?: {\n contextDir?: string;\n rootDir?: string;\n port?: number;\n host?: string;\n}): Promise<void> {\n const rootDir = options?.rootDir ?? process.cwd();\n const config = loadConfig(rootDir);\n const contextDir = options?.contextDir ?? config.context_dir;\n\n const { graph } = await compile({ contextDir, config });\n const manifest = emitManifest(graph, config);\n\n const host = options?.host ?? '0.0.0.0';\n const app = createMcpExpressApp({ host });\n\n // Stateless: new server + transport per POST (per MCP SDK pattern)\n app.post('/mcp', async (req, res) => {\n try {\n const server = createServer(manifest, graph);\n const transport = new StreamableHTTPServerTransport({\n sessionIdGenerator: undefined,\n });\n await server.connect(transport);\n await transport.handleRequest(req, res, req.body);\n res.on('close', () => {\n transport.close();\n server.close();\n });\n } catch (error) {\n if (!res.headersSent) {\n res.status(500).json({\n jsonrpc: '2.0',\n error: { code: -32603, message: 'Internal server error' },\n id: null,\n });\n }\n }\n });\n\n // GET /mcp and DELETE /mcp are not supported in stateless mode\n app.get('/mcp', (_req, res) => {\n res.writeHead(405).end(JSON.stringify({\n jsonrpc: '2.0',\n error: { code: -32000, message: 'Method not allowed.' },\n id: null,\n }));\n });\n\n app.delete('/mcp', (_req, res) => {\n res.writeHead(405).end(JSON.stringify({\n jsonrpc: '2.0',\n error: { code: -32000, message: 'Method not allowed.' },\n id: null,\n }));\n });\n\n // Health check\n app.get('/health', (_req, res) => {\n res.json({ status: 'ok', models: [...graph.models.keys()] });\n });\n\n const port = options?.port ?? 3000;\n app.listen(port, host, () => {\n console.error(`ContextKit MCP server listening on http://${host}:${port}/mcp`);\n console.error(`Health check: http://${host}:${port}/health`);\n });\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://manifest` resource.\n * Returns the full compiled manifest as JSON.\n */\nexport function registerManifestResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'manifest',\n 'context://manifest',\n { description: 'Full ContextKit manifest JSON (models, governance, rules, lineage, terms, owners, tiers)' },\n async (uri) => ({\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(manifest, null, 2),\n },\n ],\n }),\n );\n}\n","import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Build a merged view of a model: OSI model + governance + rules + lineage + tier.\n */\nexport function buildModelView(name: string, manifest: Manifest): Record<string, unknown> | null {\n const model = manifest.models[name];\n if (!model) return null;\n\n return {\n model,\n governance: manifest.governance[name] ?? null,\n rules: manifest.rules[name] ?? null,\n lineage: manifest.lineage[name] ?? null,\n tier: manifest.tiers[name] ?? null,\n };\n}\n\n/**\n * Register the `context://model/{name}` resource template.\n * Returns the OSI model merged with governance, rules, lineage, and tier data.\n */\nexport function registerModelResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'model',\n new ResourceTemplate('context://model/{name}', {\n list: async () => ({\n resources: Object.keys(manifest.models).map((name) => ({\n uri: `context://model/${name}`,\n name,\n description: manifest.models[name]?.description ?? `Model: ${name}`,\n })),\n }),\n }),\n { description: 'OSI semantic model merged with governance, rules, lineage, and tier' },\n async (uri, { name }) => {\n const modelName = String(name);\n const view = buildModelView(modelName, manifest);\n if (!view) {\n throw new Error(`Model '${modelName}' not found`);\n }\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(view, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://glossary` resource.\n * Returns all glossary terms as JSON.\n */\nexport function registerGlossaryResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'glossary',\n 'context://glossary',\n { description: 'All ContextKit glossary terms with definitions, synonyms, and mappings' },\n async (uri) => ({\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(manifest.terms, null, 2),\n },\n ],\n }),\n );\n}\n","import { McpServer, ResourceTemplate } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport type { Manifest } from '@runcontext/core';\n\n/**\n * Register the `context://tier/{name}` resource template.\n * Returns the tier scorecard for a specific model.\n */\nexport function registerTierResource(server: McpServer, manifest: Manifest): void {\n server.resource(\n 'tier',\n new ResourceTemplate('context://tier/{name}', {\n list: async () => ({\n resources: Object.keys(manifest.tiers).map((name) => ({\n uri: `context://tier/${name}`,\n name,\n description: `Tier scorecard for model: ${name} (${manifest.tiers[name]?.tier ?? 'unknown'})`,\n })),\n }),\n }),\n { description: 'Tier scorecard for a model (bronze/silver/gold checks and results)' },\n async (uri, { name }) => {\n const modelName = String(name);\n const tier = manifest.tiers[modelName];\n if (!tier) {\n throw new Error(`Tier data for model '${modelName}' not found`);\n }\n return {\n contents: [\n {\n uri: uri.href,\n mimeType: 'application/json',\n text: JSON.stringify(tier, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest } from '@runcontext/core';\n\nexport interface SearchResult {\n type: 'model' | 'dataset' | 'field' | 'term' | 'owner';\n name: string;\n description?: string;\n model?: string;\n dataset?: string;\n}\n\n/**\n * Perform keyword search across all node types in the manifest.\n */\nexport function searchManifest(manifest: Manifest, query: string): SearchResult[] {\n const results: SearchResult[] = [];\n const q = query.toLowerCase();\n\n // Search models\n for (const [name, model] of Object.entries(manifest.models)) {\n if (\n name.toLowerCase().includes(q) ||\n model.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'model',\n name,\n description: model.description,\n });\n }\n\n // Search datasets\n for (const ds of model.datasets ?? []) {\n if (\n ds.name.toLowerCase().includes(q) ||\n ds.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'dataset',\n name: ds.name,\n description: ds.description,\n model: name,\n });\n }\n\n // Search fields\n if (ds.fields) {\n for (const field of ds.fields) {\n if (\n field.name.toLowerCase().includes(q) ||\n field.description?.toLowerCase().includes(q) ||\n field.label?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'field',\n name: field.name,\n description: field.description,\n model: name,\n dataset: ds.name,\n });\n }\n }\n }\n }\n }\n\n // Search terms\n for (const [id, term] of Object.entries(manifest.terms)) {\n if (\n id.toLowerCase().includes(q) ||\n term.definition.toLowerCase().includes(q) ||\n term.synonyms?.some((s) => s.toLowerCase().includes(q))\n ) {\n results.push({\n type: 'term',\n name: id,\n description: term.definition,\n });\n }\n }\n\n // Search owners\n for (const [id, owner] of Object.entries(manifest.owners)) {\n if (\n id.toLowerCase().includes(q) ||\n owner.display_name.toLowerCase().includes(q) ||\n owner.description?.toLowerCase().includes(q)\n ) {\n results.push({\n type: 'owner',\n name: id,\n description: owner.display_name,\n });\n }\n }\n\n return results;\n}\n\n/**\n * Register the `context_search` tool.\n * Keyword search across all node types (models, datasets, fields, terms, owners).\n */\nexport function registerSearchTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_search',\n 'Search across all ContextKit nodes (models, datasets, fields, terms, owners) by keyword',\n { query: z.string().describe('Keyword to search for') },\n async ({ query }) => {\n const results = searchManifest(manifest, query);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest } from '@runcontext/core';\n\nexport interface ExplainResult {\n model: Record<string, unknown>;\n governance: Record<string, unknown> | null;\n rules: Record<string, unknown> | null;\n lineage: Record<string, unknown> | null;\n tier: Record<string, unknown> | null;\n owner: Record<string, unknown> | null;\n relatedTerms: Record<string, unknown>[];\n}\n\n/**\n * Deep lookup for a model with all related governance context.\n */\nexport function explainModel(name: string, manifest: Manifest): ExplainResult | null {\n const model = manifest.models[name];\n if (!model) return null;\n\n const governance = manifest.governance[name] ?? null;\n const rules = manifest.rules[name] ?? null;\n const lineage = manifest.lineage[name] ?? null;\n const tier = manifest.tiers[name] ?? null;\n\n // Find the owner\n const ownerKey = governance?.owner;\n const owner = ownerKey ? (manifest.owners[ownerKey] ?? null) : null;\n\n // Find related glossary terms — terms whose tags overlap with model tags\n const modelTags = governance?.tags ?? [];\n const relatedTerms: Record<string, unknown>[] = [];\n for (const [, term] of Object.entries(manifest.terms)) {\n const termTags = term.tags ?? [];\n const hasOverlap = modelTags.some((t) => termTags.includes(t));\n const mapsToModel = term.maps_to?.some((m) => m === name);\n if (hasOverlap || mapsToModel) {\n relatedTerms.push(term as unknown as Record<string, unknown>);\n }\n }\n\n return {\n model: model as unknown as Record<string, unknown>,\n governance: governance as unknown as Record<string, unknown> | null,\n rules: rules as unknown as Record<string, unknown> | null,\n lineage: lineage as unknown as Record<string, unknown> | null,\n tier: tier as unknown as Record<string, unknown> | null,\n owner: owner as unknown as Record<string, unknown> | null,\n relatedTerms,\n };\n}\n\n/**\n * Register the `context_explain` tool.\n * Deep lookup with related governance for a model.\n */\nexport function registerExplainTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_explain',\n 'Deep lookup of a model with all related governance, rules, lineage, tier, owner, and glossary terms',\n { model: z.string().describe('Name of the model to explain') },\n async ({ model }) => {\n const result = explainModel(model, manifest);\n if (!result) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({ error: `Model '${model}' not found` }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { ContextGraph, Diagnostic } from '@runcontext/core';\nimport { LintEngine, ALL_RULES } from '@runcontext/core';\n\nexport interface ValidateResult {\n totalDiagnostics: number;\n errors: number;\n warnings: number;\n diagnostics: Diagnostic[];\n}\n\n/**\n * Run the full linter against the context graph.\n */\nexport function validateGraph(graph: ContextGraph): ValidateResult {\n const engine = new LintEngine();\n for (const rule of ALL_RULES) {\n engine.register(rule);\n }\n\n const diagnostics = engine.run(graph);\n const errors = diagnostics.filter((d) => d.severity === 'error').length;\n const warnings = diagnostics.filter((d) => d.severity === 'warning').length;\n\n return {\n totalDiagnostics: diagnostics.length,\n errors,\n warnings,\n diagnostics,\n };\n}\n\n/**\n * Register the `context_validate` tool.\n * Runs the linter and returns diagnostics.\n */\nexport function registerValidateTool(server: McpServer, graph: ContextGraph): void {\n server.tool(\n 'context_validate',\n 'Run ContextKit linter against the context graph and return diagnostics',\n {},\n async () => {\n const result = validateGraph(graph);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { ContextGraph, TierScore } from '@runcontext/core';\nimport { computeTier } from '@runcontext/core';\n\n/**\n * Compute the tier for a model from the context graph.\n */\nexport function computeModelTier(modelName: string, graph: ContextGraph): TierScore | null {\n if (!graph.models.has(modelName)) return null;\n return computeTier(modelName, graph);\n}\n\n/**\n * Register the `context_tier` tool.\n * Computes the tier scorecard for a specified model.\n */\nexport function registerTierTool(server: McpServer, graph: ContextGraph): void {\n server.tool(\n 'context_tier',\n 'Compute the metadata tier (none/bronze/silver/gold) for a model with detailed check results',\n { model: z.string().describe('Name of the model to tier') },\n async ({ model }) => {\n const result = computeModelTier(model, graph);\n if (!result) {\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify({ error: `Model '${model}' not found` }),\n },\n ],\n };\n }\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(result, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest, GoldenQuery } from '@runcontext/core';\n\nexport interface GoldenQueryMatch {\n model: string;\n query: GoldenQuery;\n score: number;\n}\n\n/**\n * Find golden queries matching a natural-language question.\n * Uses simple keyword overlap scoring.\n */\nexport function findGoldenQueries(manifest: Manifest, question: string): GoldenQueryMatch[] {\n const stopWords = new Set(['a', 'an', 'the', 'is', 'in', 'on', 'at', 'to', 'of', 'for', 'and', 'or', 'not']);\n const qWords = question.toLowerCase().split(/\\s+/).filter((w) => w.length > 0 && !stopWords.has(w));\n const matches: GoldenQueryMatch[] = [];\n\n for (const [modelName, rules] of Object.entries(manifest.rules)) {\n if (!rules.golden_queries) continue;\n\n for (const gq of rules.golden_queries) {\n const gqWords = gq.question.toLowerCase().split(/\\s+/);\n const overlap = qWords.filter((w) => gqWords.some((gw) => gw.includes(w))).length;\n if (overlap > 0) {\n matches.push({\n model: modelName,\n query: gq,\n score: overlap / Math.max(qWords.length, 1),\n });\n }\n }\n }\n\n // Sort by score descending\n matches.sort((a, b) => b.score - a.score);\n return matches;\n}\n\n/**\n * Register the `context_golden_query` tool.\n * Finds golden queries matching a given question.\n */\nexport function registerGoldenQueryTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_golden_query',\n 'Find golden SQL queries that match a natural-language question',\n { question: z.string().describe('Natural-language question to match against golden queries') },\n async ({ question }) => {\n const results = findGoldenQueries(manifest, question);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n","import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';\nimport { z } from 'zod';\nimport type { Manifest, GuardrailFilter } from '@runcontext/core';\n\nexport interface GuardrailMatch {\n model: string;\n filter: GuardrailFilter;\n}\n\n/**\n * Find guardrail filters that apply to the given tables.\n */\nexport function findGuardrails(manifest: Manifest, tables: string[]): GuardrailMatch[] {\n const matches: GuardrailMatch[] = [];\n const tableSet = new Set(tables.map((t) => t.toLowerCase()));\n\n for (const [modelName, rules] of Object.entries(manifest.rules)) {\n if (!rules.guardrail_filters) continue;\n\n for (const gf of rules.guardrail_filters) {\n // A guardrail matches if:\n // 1. It has no tables restriction (applies globally), or\n // 2. Any of its tables match the requested tables\n const applies =\n !gf.tables ||\n gf.tables.length === 0 ||\n gf.tables.some((t) => tableSet.has(t.toLowerCase()));\n\n if (applies) {\n matches.push({\n model: modelName,\n filter: gf,\n });\n }\n }\n }\n\n return matches;\n}\n\n/**\n * Register the `context_guardrails` tool.\n * Returns guardrail filters for given tables.\n */\nexport function registerGuardrailsTool(server: McpServer, manifest: Manifest): void {\n server.tool(\n 'context_guardrails',\n 'Return guardrail filters that apply to the specified tables',\n {\n tables: z.array(z.string()).describe('List of table names to check guardrails for'),\n },\n async ({ tables }) => {\n const results = findGuardrails(manifest, tables);\n return {\n content: [\n {\n type: 'text' as const,\n text: JSON.stringify(results, null, 2),\n },\n ],\n };\n },\n );\n}\n"],"mappings":";AAAA,SAAS,aAAAA,kBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,qCAAqC;AAC9C,SAAS,2BAA2B;AAEpC,SAAS,SAAS,cAAc,kBAAkB;;;ACE3C,SAAS,yBAAyB,QAAmB,UAA0B;AACpF,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,EAAE,aAAa,2FAA2F;AAAA,IAC1G,OAAO,SAAS;AAAA,MACd,UAAU;AAAA,QACR;AAAA,UACE,KAAK,IAAI;AAAA,UACT,UAAU;AAAA,UACV,MAAM,KAAK,UAAU,UAAU,MAAM,CAAC;AAAA,QACxC;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;;;ACtBA,SAAoB,wBAAwB;AAMrC,SAAS,eAAe,MAAc,UAAoD;AAC/F,QAAM,QAAQ,SAAS,OAAO,IAAI;AAClC,MAAI,CAAC,MAAO,QAAO;AAEnB,SAAO;AAAA,IACL;AAAA,IACA,YAAY,SAAS,WAAW,IAAI,KAAK;AAAA,IACzC,OAAO,SAAS,MAAM,IAA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AA,MACpC,SAAS;AAAA,MACT,OAAO,EAAE,MAAM,OAAQ,SAAS,sBAAsB;AAAA,MACtD,IAAI;AAAA,IACN,CAAC,CAAC;AAAA,EACJ,CAAC;AAGD,MAAI,IAAI,WAAW,CAAC,MAAM,QAAQ;AAChC,QAAI,KAAK,EAAE,QAAQ,MAAM,QAAQ,CAAC,GAAG,MAAM,OAAO,KAAK,CAAC,EAAE,CAAC;AAAA,EAC7D,CAAC;AAED,QAAM,OAAO,SAAS,QAAQ;AAC9B,MAAI,OAAO,MAAM,MAAM,MAAM;AAC3B,YAAQ,MAAM,6CAA6C,IAAI,IAAI,IAAI,MAAM;AAC7E,YAAQ,MAAM,wBAAwB,IAAI,IAAI,IAAI,SAAS;AAAA,EAC7D,CAAC;AACH;","names":["McpServer","ResourceTemplate","z","z","z","z","McpServer"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runcontext/mcp",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "MCP server for exposing ContextKit context to AI agents",
5
5
  "license": "MIT",
6
6
  "author": "Eric Kittelson",
@@ -10,7 +10,13 @@
10
10
  "url": "https://github.com/erickittelson/ContextKit.git",
11
11
  "directory": "packages/mcp"
12
12
  },
13
- "keywords": ["contextkit", "mcp", "model-context-protocol", "ai", "llm"],
13
+ "keywords": [
14
+ "contextkit",
15
+ "mcp",
16
+ "model-context-protocol",
17
+ "ai",
18
+ "llm"
19
+ ],
14
20
  "type": "module",
15
21
  "main": "./dist/index.cjs",
16
22
  "module": "./dist/index.mjs",
@@ -27,13 +33,11 @@
27
33
  }
28
34
  }
29
35
  },
30
- "files": ["dist"],
31
- "scripts": {
32
- "build": "tsup",
33
- "clean": "rm -rf dist"
34
- },
36
+ "files": [
37
+ "dist"
38
+ ],
35
39
  "dependencies": {
36
- "@runcontext/core": "^0.3.2",
40
+ "@runcontext/core": "^0.3.4",
37
41
  "@modelcontextprotocol/sdk": "^1.12.0",
38
42
  "express": "^5.1.0",
39
43
  "zod": "^3.24.0"
@@ -44,5 +48,9 @@
44
48
  "tsup": "^8.4.0",
45
49
  "typescript": "^5.7.0",
46
50
  "vitest": "^3.2.0"
51
+ },
52
+ "scripts": {
53
+ "build": "tsup",
54
+ "clean": "rm -rf dist"
47
55
  }
48
- }
56
+ }