@cocaxcode/ai-context-inspector 0.3.2 → 0.4.0

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,179 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- generateHtml,
4
- introspectServers,
5
- runAllScanners,
6
- scanMcpConfigs
7
- } from "./chunk-G57UDS2C.js";
8
-
9
- // src/server.ts
10
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
11
-
12
- // src/tools/scan.ts
13
- import { z } from "zod";
14
- function registerScanTool(server) {
15
- server.tool(
16
- "scan",
17
- "Escanea un proyecto y descubre todo su ecosistema AI: MCP servers, archivos de contexto, skills y memorias",
18
- {
19
- dir: z.string().optional().describe("Directorio a escanear (default: cwd)"),
20
- include_user: z.boolean().optional().describe("Incluir configuraci\xF3n del usuario"),
21
- no_introspect: z.boolean().optional().describe("No conectar a MCP servers"),
22
- timeout: z.number().optional().describe("Timeout de introspecci\xF3n en ms (default: 10000)")
23
- },
24
- async ({ dir, include_user, no_introspect, timeout }) => {
25
- try {
26
- const result = await runAllScanners({
27
- dir: dir ?? process.cwd(),
28
- includeUser: include_user ?? false,
29
- introspect: !(no_introspect ?? false),
30
- timeout: timeout ?? 1e4
31
- });
32
- return {
33
- content: [
34
- {
35
- type: "text",
36
- text: JSON.stringify(result, null, 2)
37
- }
38
- ]
39
- };
40
- } catch (err) {
41
- return {
42
- isError: true,
43
- content: [
44
- {
45
- type: "text",
46
- text: `Error escaneando: ${err.message}`
47
- }
48
- ]
49
- };
50
- }
51
- }
52
- );
53
- }
54
-
55
- // src/tools/introspect.ts
56
- import { z as z2 } from "zod";
57
- function registerIntrospectTool(server) {
58
- server.tool(
59
- "introspect_mcp",
60
- "Introspecciona un MCP server espec\xEDfico: lista sus tools, resources y prompts",
61
- {
62
- server_name: z2.string().describe("Nombre del server MCP a introspeccionar"),
63
- dir: z2.string().optional().describe("Directorio del proyecto (default: cwd)"),
64
- timeout: z2.number().optional().describe("Timeout en ms (default: 10000)")
65
- },
66
- async ({ server_name, dir, timeout }) => {
67
- try {
68
- const { servers } = await scanMcpConfigs({
69
- dir: dir ?? process.cwd(),
70
- includeUser: true
71
- });
72
- const target = servers.find((s) => s.name === server_name);
73
- if (!target) {
74
- return {
75
- isError: true,
76
- content: [
77
- {
78
- type: "text",
79
- text: `Server '${server_name}' no encontrado en la configuraci\xF3n. Servers disponibles: ${servers.map((s) => s.name).join(", ") || "(ninguno)"}`
80
- }
81
- ]
82
- };
83
- }
84
- await introspectServers([target], timeout ?? 1e4);
85
- return {
86
- content: [
87
- {
88
- type: "text",
89
- text: JSON.stringify(target, null, 2)
90
- }
91
- ]
92
- };
93
- } catch (err) {
94
- return {
95
- isError: true,
96
- content: [
97
- {
98
- type: "text",
99
- text: `Error introspectando: ${err.message}`
100
- }
101
- ]
102
- };
103
- }
104
- }
105
- );
106
- }
107
-
108
- // src/tools/report.ts
109
- import { z as z3 } from "zod";
110
- import { mkdir, writeFile } from "fs/promises";
111
- import { dirname, resolve } from "path";
112
- function registerReportTool(server) {
113
- server.tool(
114
- "generate_report",
115
- "Genera un dashboard HTML interactivo con el ecosistema AI del proyecto",
116
- {
117
- dir: z3.string().optional().describe("Directorio a escanear (default: cwd)"),
118
- output: z3.string().optional().describe("Ruta del archivo HTML (default: ai-context-report.html)"),
119
- include_user: z3.boolean().optional().describe("Incluir configuraci\xF3n del usuario (~/.claude, skills, memorias, agentes)"),
120
- no_introspect: z3.boolean().optional().describe("No conectar a MCP servers"),
121
- timeout: z3.number().optional().describe("Timeout de introspecci\xF3n en ms (default: 10000)")
122
- },
123
- async ({ dir, output, include_user, no_introspect, timeout }) => {
124
- try {
125
- const result = await runAllScanners({
126
- dir: dir ?? process.cwd(),
127
- includeUser: include_user ?? false,
128
- introspect: !(no_introspect ?? false),
129
- timeout: timeout ?? 1e4
130
- });
131
- const html = generateHtml(result);
132
- const outputPath = resolve(output ?? "ai-context-report.html");
133
- await mkdir(dirname(outputPath), { recursive: true });
134
- await writeFile(outputPath, html, "utf-8");
135
- return {
136
- content: [
137
- {
138
- type: "text",
139
- text: `Reporte generado: ${outputPath}
140
-
141
- Resumen:
142
- - MCP Servers: ${result.mcpServers.length}
143
- - Tools: ${result.mcpServers.reduce((s, m) => s + (m.introspection?.tools.length ?? 0), 0)}
144
- - Archivos: ${result.contextFiles.length}
145
- - Skills: ${result.skills.length}
146
- - Memorias: ${result.memories.length}`
147
- }
148
- ]
149
- };
150
- } catch (err) {
151
- return {
152
- isError: true,
153
- content: [
154
- {
155
- type: "text",
156
- text: `Error generando reporte: ${err.message}`
157
- }
158
- ]
159
- };
160
- }
161
- }
162
- );
163
- }
164
-
165
- // src/server.ts
166
- var VERSION = "0.1.0";
167
- function createServer() {
168
- const server = new McpServer({
169
- name: "ai-context-inspector",
170
- version: VERSION
171
- });
172
- registerScanTool(server);
173
- registerIntrospectTool(server);
174
- registerReportTool(server);
175
- return server;
176
- }
177
- export {
178
- createServer
179
- };