@aiready/mcp-server 0.1.17 → 0.1.19

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.
@@ -1,16 +1,17 @@
1
-
2
- > @aiready/mcp-server@0.1.17 build /Users/pengcao/projects/aiready/packages/mcp-server
3
- > tsup src/index.ts --format esm --clean --dts
4
-
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.1
8
- CLI Using tsup config: /Users/pengcao/projects/aiready/packages/mcp-server/tsup.config.ts
9
- CLI Target: node20
10
- CLI Cleaning output folder
11
- ESM Build start
12
- ESM dist/index.js 2.90 KB
13
- ESM ⚡️ Build success in 26ms
14
- DTS Build start
15
- DTS ⚡️ Build success in 3194ms
16
- DTS dist/index.d.ts 430.00 B
1
+
2
+ 
3
+ > @aiready/mcp-server@0.1.19 build /Users/pengcao/projects/aiready/packages/mcp-server
4
+ > tsup src/index.ts --format esm --clean --dts
5
+
6
+ CLI Building entry: src/index.ts
7
+ CLI Using tsconfig: tsconfig.json
8
+ CLI tsup v8.5.1
9
+ CLI Using tsup config: /Users/pengcao/projects/aiready/packages/mcp-server/tsup.config.ts
10
+ CLI Target: node20
11
+ CLI Cleaning output folder
12
+ ESM Build start
13
+ ESM dist/index.js 4.81 KB
14
+ ESM ⚡️ Build success in 82ms
15
+ DTS Build start
16
+ DTS ⚡️ Build success in 5011ms
17
+ DTS dist/index.d.ts 430.00 B
@@ -1,10 +1,5 @@
1
-
2
- > @aiready/mcp-server@0.1.0 lint /Users/pengcao/projects/aiready/packages/mcp-server
3
- > eslint src
4
-
5
-
6
- /Users/pengcao/projects/aiready/packages/mcp-server/src/index.ts
7
- 7:24 warning 'ToolName' is defined but never used @typescript-eslint/no-unused-vars
8
-
9
- ✖ 1 problem (0 errors, 1 warning)
10
-
1
+
2
+ 
3
+ > @aiready/mcp-server@0.1.17 lint /Users/pengcao/projects/aiready/packages/mcp-server
4
+ > eslint src
5
+
@@ -1,16 +1,22 @@
1
-
2
- > @aiready/mcp-server@0.1.13 test /Users/pengcao/projects/aiready/packages/mcp-server
3
- > vitest run
4
-
5
-
6
-  RUN  v4.0.18 /Users/pengcao/projects/aiready/packages/mcp-server
7
-
8
- AIReady MCP Server started
9
- [MCP] Executing pattern-detect on /Users/pengcao/projects/aiready/packages/core
10
- ✓ src/__tests__/server.test.ts (5 tests) 1096ms
11
-
12
-  Test Files  1 passed (1)
13
-  Tests  5 passed (5)
14
-  Start at  12:24:46
15
-  Duration  1.41s (transform 81ms, setup 0ms, import 132ms, tests 1.10s, environment 0ms)
16
-
1
+
2
+ 
3
+ > @aiready/mcp-server@0.1.18 test /Users/pengcao/projects/aiready/packages/mcp-server
4
+ > vitest run
5
+
6
+ [?25l
7
+  RUN  v4.0.18 /Users/pengcao/projects/aiready/packages/mcp-server
8
+
9
+ AIReady MCP Server started
10
+ [MCP] Dynamically loading @aiready/pattern-detect for tool pattern-detect
11
+ [MCP] Executing pattern-detect on /Users/pengcao/projects/aiready/packages/core
12
+ [MCP] Dynamically loading @aiready/non-existent-tool for tool non-existent-tool
13
+ [MCP] Failed to load tool package @aiready/non-existent-tool: Cannot find package '@aiready/non-existent-tool' imported from /Users/pengcao/projects/aiready/packages/mcp-server/dist/index.js
14
+ ✓ src/__tests__/server.test.ts (5 tests) 2991ms
15
+ ✓ should execute pattern-detect and return results  1587ms
16
+
17
+  Test Files  1 passed (1)
18
+  Tests  5 passed (5)
19
+  Start at  23:31:26
20
+  Duration  3.55s (transform 98ms, setup 0ms, import 157ms, tests 2.99s, environment 0ms)
21
+
22
+ [?25h
package/dist/index.js CHANGED
@@ -7,10 +7,29 @@ import {
7
7
  CallToolRequestSchema,
8
8
  ListToolsRequestSchema
9
9
  } from "@modelcontextprotocol/sdk/types.js";
10
- import { ToolRegistry } from "@aiready/core";
11
- import "@aiready/pattern-detect";
12
- import "@aiready/context-analyzer";
13
- import "@aiready/consistency";
10
+ import { ToolRegistry, ToolName } from "@aiready/core";
11
+ var TOOL_PACKAGE_MAP = {
12
+ [ToolName.PatternDetect]: "@aiready/pattern-detect",
13
+ [ToolName.ContextAnalyzer]: "@aiready/context-analyzer",
14
+ [ToolName.NamingConsistency]: "@aiready/consistency",
15
+ [ToolName.AiSignalClarity]: "@aiready/ai-signal-clarity",
16
+ [ToolName.AgentGrounding]: "@aiready/agent-grounding",
17
+ [ToolName.TestabilityIndex]: "@aiready/testability",
18
+ [ToolName.DocDrift]: "@aiready/doc-drift",
19
+ [ToolName.DependencyHealth]: "@aiready/deps",
20
+ [ToolName.ChangeAmplification]: "@aiready/change-amplification",
21
+ // Aliases
22
+ patterns: "@aiready/pattern-detect",
23
+ duplicates: "@aiready/pattern-detect",
24
+ context: "@aiready/context-analyzer",
25
+ fragmentation: "@aiready/context-analyzer",
26
+ consistency: "@aiready/consistency",
27
+ "ai-signal": "@aiready/ai-signal-clarity",
28
+ grounding: "@aiready/agent-grounding",
29
+ testability: "@aiready/testability",
30
+ "deps-health": "@aiready/deps",
31
+ "change-amp": "@aiready/change-amplification"
32
+ };
14
33
  var AIReadyMcpServer = class {
15
34
  constructor() {
16
35
  this.server = new Server(
@@ -31,11 +50,21 @@ var AIReadyMcpServer = class {
31
50
  }
32
51
  setupHandlers() {
33
52
  this.server.setRequestHandler(ListToolsRequestSchema, async () => {
34
- const providers = ToolRegistry.getAll();
53
+ const toolsToAdvertise = [
54
+ ToolName.PatternDetect,
55
+ ToolName.ContextAnalyzer,
56
+ ToolName.NamingConsistency,
57
+ ToolName.AiSignalClarity,
58
+ ToolName.AgentGrounding,
59
+ ToolName.TestabilityIndex,
60
+ ToolName.DocDrift,
61
+ ToolName.DependencyHealth,
62
+ ToolName.ChangeAmplification
63
+ ];
35
64
  return {
36
- tools: providers.map((p) => ({
37
- name: p.id,
38
- description: `AIReady analysis tool: ${p.id}`,
65
+ tools: toolsToAdvertise.map((id) => ({
66
+ name: id,
67
+ description: `AIReady analysis tool: ${id}`,
39
68
  inputSchema: {
40
69
  type: "object",
41
70
  properties: {
@@ -53,9 +82,28 @@ var AIReadyMcpServer = class {
53
82
  this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
54
83
  const { name, arguments: args } = request.params;
55
84
  try {
56
- const provider = ToolRegistry.find(name);
85
+ let provider = ToolRegistry.find(name);
86
+ if (!provider) {
87
+ const packageName = TOOL_PACKAGE_MAP[name] ?? (name.startsWith("@aiready/") ? name : `@aiready/${name}`);
88
+ try {
89
+ console.error(
90
+ `[MCP] Dynamically loading ${packageName} for tool ${name}`
91
+ );
92
+ await import(packageName);
93
+ provider = ToolRegistry.find(name);
94
+ } catch (importError) {
95
+ console.error(
96
+ `[MCP] Failed to load tool package ${packageName}: ${importError.message}`
97
+ );
98
+ const error = new Error(
99
+ `Tool ${name} not found and failed to load package ${packageName}: ${importError.message}`
100
+ );
101
+ error.cause = importError;
102
+ throw error;
103
+ }
104
+ }
57
105
  if (!provider) {
58
- throw new Error(`Tool ${name} not found`);
106
+ throw new Error(`Tool ${name} not found after attempting to load`);
59
107
  }
60
108
  if (!args || typeof args.path !== "string") {
61
109
  throw new Error("Missing required argument: path");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiready/mcp-server",
3
- "version": "0.1.17",
3
+ "version": "0.1.19",
4
4
  "description": "AIReady Model Context Protocol (MCP) Server",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -13,10 +13,10 @@
13
13
  "@modelcontextprotocol/sdk": "^1.0.0",
14
14
  "chalk": "^5.3.0",
15
15
  "zod": "^4.3.6",
16
- "@aiready/consistency": "0.20.18",
17
- "@aiready/core": "0.23.19",
18
- "@aiready/context-analyzer": "0.21.22",
19
- "@aiready/pattern-detect": "0.16.18"
16
+ "@aiready/consistency": "0.20.20",
17
+ "@aiready/context-analyzer": "0.21.24",
18
+ "@aiready/core": "0.23.21",
19
+ "@aiready/pattern-detect": "0.16.20"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/node": "^24.0.0",
package/src/index.ts CHANGED
@@ -4,14 +4,34 @@ import {
4
4
  CallToolRequestSchema,
5
5
  ListToolsRequestSchema,
6
6
  } from '@modelcontextprotocol/sdk/types.js';
7
- import { ToolRegistry } from '@aiready/core';
7
+ import { ToolRegistry, ToolName } from '@aiready/core';
8
8
 
9
- // Pre-load essential tools (following CLI pattern)
10
- // In a real implementation, we would want to dynamically load these
11
- // or have them as peer dependencies.
12
- import '@aiready/pattern-detect';
13
- import '@aiready/context-analyzer';
14
- import '@aiready/consistency';
9
+ /**
10
+ * Mapping between tool names and @aiready/ package names.
11
+ * Used for dynamic registration on-demand to minimize initial context budget.
12
+ */
13
+ const TOOL_PACKAGE_MAP: Record<string, string> = {
14
+ [ToolName.PatternDetect]: '@aiready/pattern-detect',
15
+ [ToolName.ContextAnalyzer]: '@aiready/context-analyzer',
16
+ [ToolName.NamingConsistency]: '@aiready/consistency',
17
+ [ToolName.AiSignalClarity]: '@aiready/ai-signal-clarity',
18
+ [ToolName.AgentGrounding]: '@aiready/agent-grounding',
19
+ [ToolName.TestabilityIndex]: '@aiready/testability',
20
+ [ToolName.DocDrift]: '@aiready/doc-drift',
21
+ [ToolName.DependencyHealth]: '@aiready/deps',
22
+ [ToolName.ChangeAmplification]: '@aiready/change-amplification',
23
+ // Aliases
24
+ patterns: '@aiready/pattern-detect',
25
+ duplicates: '@aiready/pattern-detect',
26
+ context: '@aiready/context-analyzer',
27
+ fragmentation: '@aiready/context-analyzer',
28
+ consistency: '@aiready/consistency',
29
+ 'ai-signal': '@aiready/ai-signal-clarity',
30
+ grounding: '@aiready/agent-grounding',
31
+ testability: '@aiready/testability',
32
+ 'deps-health': '@aiready/deps',
33
+ 'change-amp': '@aiready/change-amplification',
34
+ };
15
35
 
16
36
  /**
17
37
  * AIReady MCP Server Implementation
@@ -42,12 +62,24 @@ export class AIReadyMcpServer {
42
62
  private setupHandlers() {
43
63
  // List available tools
44
64
  this.server.setRequestHandler(ListToolsRequestSchema, async () => {
45
- const providers = ToolRegistry.getAll();
65
+ // Define canonical tool names to advertise to the client
66
+ // These will be dynamically loaded on demand
67
+ const toolsToAdvertise = [
68
+ ToolName.PatternDetect,
69
+ ToolName.ContextAnalyzer,
70
+ ToolName.NamingConsistency,
71
+ ToolName.AiSignalClarity,
72
+ ToolName.AgentGrounding,
73
+ ToolName.TestabilityIndex,
74
+ ToolName.DocDrift,
75
+ ToolName.DependencyHealth,
76
+ ToolName.ChangeAmplification,
77
+ ];
46
78
 
47
79
  return {
48
- tools: providers.map((p) => ({
49
- name: p.id,
50
- description: `AIReady analysis tool: ${p.id}`,
80
+ tools: toolsToAdvertise.map((id) => ({
81
+ name: id,
82
+ description: `AIReady analysis tool: ${id}`,
51
83
  inputSchema: {
52
84
  type: 'object',
53
85
  properties: {
@@ -68,9 +100,34 @@ export class AIReadyMcpServer {
68
100
  const { name, arguments: args } = request.params;
69
101
 
70
102
  try {
71
- const provider = ToolRegistry.find(name);
103
+ let provider = ToolRegistry.find(name);
104
+
105
+ // Dynamic loading if not already registered (CLI pattern)
106
+ if (!provider) {
107
+ const packageName =
108
+ TOOL_PACKAGE_MAP[name] ??
109
+ (name.startsWith('@aiready/') ? name : `@aiready/${name}`);
110
+
111
+ try {
112
+ console.error(
113
+ `[MCP] Dynamically loading ${packageName} for tool ${name}`
114
+ );
115
+ await import(packageName);
116
+ provider = ToolRegistry.find(name);
117
+ } catch (importError: any) {
118
+ console.error(
119
+ `[MCP] Failed to load tool package ${packageName}: ${importError.message}`
120
+ );
121
+ const error = new Error(
122
+ `Tool ${name} not found and failed to load package ${packageName}: ${importError.message}`
123
+ );
124
+ (error as any).cause = importError;
125
+ throw error;
126
+ }
127
+ }
128
+
72
129
  if (!provider) {
73
- throw new Error(`Tool ${name} not found`);
130
+ throw new Error(`Tool ${name} not found after attempting to load`);
74
131
  }
75
132
 
76
133
  if (!args || typeof args.path !== 'string') {