@semacode/mcp 1.2.17 → 1.2.18
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/package.json +1 -1
- package/.deploy/docker-compose.sema-mcp.yml +0 -11
- package/.deploy/sema-mcp-deploy.tar.gz +0 -0
- package/.deploy/semacode-cli-1.2.17.tgz +0 -0
- package/Dockerfile +0 -20
- package/src/index.ts +0 -173
- package/tsconfig.json +0 -9
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
package/Dockerfile
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
FROM node:22-alpine
|
|
2
|
-
|
|
3
|
-
WORKDIR /app
|
|
4
|
-
|
|
5
|
-
# Instala a CLI da Sema a partir do pacote local empacotado
|
|
6
|
-
COPY semacode-cli-1.2.17.tgz /tmp/semacode-cli.tgz
|
|
7
|
-
RUN npm install -g /tmp/semacode-cli.tgz && rm /tmp/semacode-cli.tgz
|
|
8
|
-
|
|
9
|
-
# Copia o servidor MCP ja compilado
|
|
10
|
-
COPY dist/ ./dist/
|
|
11
|
-
COPY package.json ./
|
|
12
|
-
|
|
13
|
-
# Instala apenas as dependencias de producao do pacote mcp
|
|
14
|
-
RUN npm install --omit=dev
|
|
15
|
-
|
|
16
|
-
EXPOSE 3010
|
|
17
|
-
|
|
18
|
-
ENV MCP_PORT=3010
|
|
19
|
-
|
|
20
|
-
CMD ["node", "dist/index.js"]
|
package/src/index.ts
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { createServer, IncomingMessage, ServerResponse } from "node:http";
|
|
3
|
-
import { spawnSync } from "node:child_process";
|
|
4
|
-
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
-
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
-
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
7
|
-
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
|
|
10
|
-
function chamarSema(args: string[], cwd?: string): string {
|
|
11
|
-
const resultado = spawnSync("sema", args, {
|
|
12
|
-
encoding: "utf-8",
|
|
13
|
-
cwd: cwd ?? process.cwd(),
|
|
14
|
-
env: process.env,
|
|
15
|
-
shell: true,
|
|
16
|
-
});
|
|
17
|
-
const saida = (resultado.stdout ?? "").trim();
|
|
18
|
-
const erro = (resultado.stderr ?? "").trim();
|
|
19
|
-
if (resultado.error) {
|
|
20
|
-
return `Erro ao chamar sema: ${resultado.error.message}`;
|
|
21
|
-
}
|
|
22
|
-
return [saida, erro].filter(Boolean).join("\n");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const server = new McpServer({
|
|
26
|
-
name: "sema",
|
|
27
|
-
version: "1.2.17",
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
server.tool(
|
|
31
|
-
"sema_validar",
|
|
32
|
-
"Valida um arquivo .sema e retorna diagnosticos de erro ou sucesso.",
|
|
33
|
-
{ arquivo: z.string().describe("Caminho absoluto ou relativo para o arquivo .sema") },
|
|
34
|
-
async ({ arquivo }) => ({
|
|
35
|
-
content: [{ type: "text", text: chamarSema(["validar", arquivo]) }],
|
|
36
|
-
})
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
server.tool(
|
|
40
|
-
"sema_ir",
|
|
41
|
-
"Compila um arquivo .sema e retorna a representacao intermediaria (IR) em JSON.",
|
|
42
|
-
{ arquivo: z.string().describe("Caminho para o arquivo .sema") },
|
|
43
|
-
async ({ arquivo }) => ({
|
|
44
|
-
content: [{ type: "text", text: chamarSema(["ir", arquivo, "--json"]) }],
|
|
45
|
-
})
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
server.tool(
|
|
49
|
-
"sema_drift",
|
|
50
|
-
"Analisa o drift entre o contrato .sema e o codigo do projeto. Retorna divergencias encontradas.",
|
|
51
|
-
{
|
|
52
|
-
projeto: z.string().optional().describe("Caminho do projeto (padrao: diretorio atual)"),
|
|
53
|
-
json: z.boolean().optional().describe("Retornar saida em JSON"),
|
|
54
|
-
},
|
|
55
|
-
async ({ projeto, json }) => {
|
|
56
|
-
const args = ["drift", ...(projeto ? [projeto] : []), ...(json ? ["--json"] : [])];
|
|
57
|
-
return { content: [{ type: "text", text: chamarSema(args, projeto) }] };
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
server.tool(
|
|
62
|
-
"sema_resumo",
|
|
63
|
-
"Gera um resumo IA-first do projeto Sema com modulos, riscos e lacunas.",
|
|
64
|
-
{
|
|
65
|
-
projeto: z.string().optional().describe("Caminho do projeto (padrao: diretorio atual)"),
|
|
66
|
-
tamanho: z
|
|
67
|
-
.enum(["micro", "curto", "medio"])
|
|
68
|
-
.optional()
|
|
69
|
-
.describe("Tamanho do resumo (padrao: curto)"),
|
|
70
|
-
},
|
|
71
|
-
async ({ projeto, tamanho }) => {
|
|
72
|
-
const args = [
|
|
73
|
-
"resumo",
|
|
74
|
-
...(tamanho ? [`--tamanho=${tamanho}`] : []),
|
|
75
|
-
];
|
|
76
|
-
return { content: [{ type: "text", text: chamarSema(args, projeto) }] };
|
|
77
|
-
}
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
server.tool(
|
|
81
|
-
"sema_prompt_ia",
|
|
82
|
-
"Gera o prompt-curto IA-first do projeto para briefar um agente sobre o estado atual.",
|
|
83
|
-
{ projeto: z.string().optional().describe("Caminho do projeto") },
|
|
84
|
-
async ({ projeto }) => ({
|
|
85
|
-
content: [{ type: "text", text: chamarSema(["prompt-curto"], projeto) }],
|
|
86
|
-
})
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
server.tool(
|
|
90
|
-
"sema_contexto_ia",
|
|
91
|
-
"Gera o pacote completo de contexto IA para um modulo ou projeto (briefing, drift, IR, artefatos).",
|
|
92
|
-
{ arquivo: z.string().describe("Caminho para o arquivo .sema do modulo") },
|
|
93
|
-
async ({ arquivo }) => ({
|
|
94
|
-
content: [{ type: "text", text: chamarSema(["contexto-ia", arquivo]) }],
|
|
95
|
-
})
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
server.tool(
|
|
99
|
-
"sema_verificar",
|
|
100
|
-
"Verifica todos os alvos de geracao de um projeto Sema (compila, gera e testa cada alvo).",
|
|
101
|
-
{
|
|
102
|
-
projeto: z.string().describe("Caminho do projeto a verificar"),
|
|
103
|
-
saida: z.string().optional().describe("Pasta de saida dos artefatos gerados"),
|
|
104
|
-
},
|
|
105
|
-
async ({ projeto, saida }) => {
|
|
106
|
-
const args = ["verificar", projeto, ...(saida ? ["--saida", saida] : [])];
|
|
107
|
-
return { content: [{ type: "text", text: chamarSema(args) }] };
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
server.tool(
|
|
112
|
-
"sema_inspecionar",
|
|
113
|
-
"Inspeciona um arquivo .sema e mostra detalhes do modulo: rotas, tarefas, eventos, politicas.",
|
|
114
|
-
{ arquivo: z.string().describe("Caminho para o arquivo .sema") },
|
|
115
|
-
async ({ arquivo }) => ({
|
|
116
|
-
content: [{ type: "text", text: chamarSema(["inspecionar", arquivo]) }],
|
|
117
|
-
})
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
const porta = process.env["MCP_PORT"] ? parseInt(process.env["MCP_PORT"]) : null;
|
|
121
|
-
|
|
122
|
-
if (porta) {
|
|
123
|
-
// Modo Streamable HTTP — protocolo MCP moderno para acesso remoto
|
|
124
|
-
const transportes = new Map<string, StreamableHTTPServerTransport>();
|
|
125
|
-
|
|
126
|
-
const http = createServer(async (req: IncomingMessage, res: ServerResponse) => {
|
|
127
|
-
const url = req.url ?? "/";
|
|
128
|
-
|
|
129
|
-
if (url === "/mcp") {
|
|
130
|
-
if (req.method === "POST") {
|
|
131
|
-
// Sessao stateless ou nova sessao stateful
|
|
132
|
-
const sessionId = req.headers["mcp-session-id"] as string | undefined;
|
|
133
|
-
let transport = sessionId ? transportes.get(sessionId) : undefined;
|
|
134
|
-
|
|
135
|
-
if (!transport) {
|
|
136
|
-
// Nova sessao
|
|
137
|
-
transport = new StreamableHTTPServerTransport({
|
|
138
|
-
sessionIdGenerator: () => crypto.randomUUID(),
|
|
139
|
-
onsessioninitialized: (id) => { transportes.set(id, transport!); },
|
|
140
|
-
});
|
|
141
|
-
transport.onclose = () => {
|
|
142
|
-
if (transport!.sessionId) transportes.delete(transport!.sessionId);
|
|
143
|
-
};
|
|
144
|
-
await server.connect(transport);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
await transport.handleRequest(req, res);
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (req.method === "GET" || req.method === "DELETE") {
|
|
152
|
-
const sessionId = req.headers["mcp-session-id"] as string | undefined;
|
|
153
|
-
const transport = sessionId ? transportes.get(sessionId) : undefined;
|
|
154
|
-
if (!transport) {
|
|
155
|
-
res.writeHead(404).end("Sessao nao encontrada");
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
await transport.handleRequest(req, res);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
res.writeHead(404).end();
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
http.listen(porta, () => {
|
|
167
|
-
process.stderr.write(`sema-mcp rodando em HTTP na porta ${porta} (endpoint: /mcp)\n`);
|
|
168
|
-
});
|
|
169
|
-
} else {
|
|
170
|
-
// Modo stdio — para uso local / Claude Code
|
|
171
|
-
const transport = new StdioServerTransport();
|
|
172
|
-
await server.connect(transport);
|
|
173
|
-
}
|