-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
99 lines (91 loc) · 2.49 KB
/
server.js
File metadata and controls
99 lines (91 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
const { z } = require("zod");
const { McpServer } = require("@modelcontextprotocol/sdk/server/mcp.js");
const { parseJsonlFile, exportPblMarkdown } = require("./lib/pbl.js");
function buildServer() {
const server = new McpServer({
name: "mcp-transcript",
version: "1.0.0"
});
server.registerTool(
"transcript_health",
{
description: "Verifica que el servidor MCP de transcript esta activo"
},
async () => ({
content: [
{
type: "text",
text: "Servidor MCP transcript activo."
}
]
})
);
server.registerTool(
"pbl_parse_jsonl",
{
description: "Parsea un archivo JSONL exportado de Claude y devuelve resumen de turnos",
inputSchema: {
inputPath: z.string().min(1)
}
},
async ({ inputPath }) => {
const parsed = await parseJsonlFile(inputPath);
const preview = parsed.turns
.slice(0, 5)
.map((t) => `${t.index}. [${t.role}] ${t.text.slice(0, 120)}`)
.join("\n");
return {
content: [
{
type: "text",
text:
`JSONL procesado: ${inputPath}\n` +
`Lineas: ${parsed.totalLines}\n` +
`Turnos validos: ${parsed.parsedTurns}\n` +
`Errores JSON: ${parsed.errors.length}\n\n` +
`Preview:\n${preview || "Sin turnos"}`
}
],
structuredContent: {
...parsed,
preview: parsed.turns.slice(0, 5)
}
};
}
);
server.registerTool(
"pbl_export_markdown",
{
description:
"Genera bitacora PBL en Markdown desde JSONL y la escribe en docs/ (por defecto docs/pbl/<archivo>-pbl.md)",
inputSchema: {
inputPath: z.string().min(1),
outputPath: z.string().min(1).optional(),
title: z.string().min(1).optional(),
projectName: z.string().min(1).optional()
}
},
async ({ inputPath, outputPath, title, projectName }) => {
const result = await exportPblMarkdown({
inputPath,
outputPath,
title,
projectName
});
return {
content: [
{
type: "text",
text:
`Bitacora PBL generada en: ${result.outputPath}\n` +
`Turnos exportados: ${result.parsedTurns}\n` +
`Errores JSONL: ${result.errors.length}`
}
],
structuredContent: result
};
}
);
return server;
}
module.exports = { buildServer };