pdc-mcp 0.6.0 → 0.7.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.
- package/README.md +1 -0
- package/dist/index.js +47 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,6 +91,7 @@ própria: é o formato que o terminal torna clicável (Cmd/Ctrl + clique).
|
|
|
91
91
|
| Tool | O quê |
|
|
92
92
|
|---|---|
|
|
93
93
|
| `pdc_auth_status` | Estado do login; inicia o device flow quando deslogado |
|
|
94
|
+
| `pdc_logout` | Sai da conta: encerra a sessão no servidor e apaga o token desta máquina |
|
|
94
95
|
| `pdc_detect_context` | Repo/branch/Dockerfile/porta do diretório local |
|
|
95
96
|
| `pdc_list_projects` / `pdc_get_project` | Projetos e detalhe (ambientes, deploys, banco) |
|
|
96
97
|
| `pdc_list_repos` / `pdc_list_branches` | Repos e branches do GitHub do usuário |
|
package/dist/index.js
CHANGED
|
@@ -20172,6 +20172,17 @@ async function saveToken(baseUrl, cred, dir) {
|
|
|
20172
20172
|
`);
|
|
20173
20173
|
await chmod(path, 384);
|
|
20174
20174
|
}
|
|
20175
|
+
async function clearToken(baseUrl, dir) {
|
|
20176
|
+
const data = await readFile(dir);
|
|
20177
|
+
delete data.servers[serverKey(baseUrl)];
|
|
20178
|
+
if (Object.keys(data.servers).length === 0) {
|
|
20179
|
+
await rm(credentialsPath(dir), { force: true });
|
|
20180
|
+
return;
|
|
20181
|
+
}
|
|
20182
|
+
await writeFile(credentialsPath(dir), JSON.stringify(data, null, 2) + `
|
|
20183
|
+
`);
|
|
20184
|
+
await chmod(credentialsPath(dir), 384);
|
|
20185
|
+
}
|
|
20175
20186
|
// ../core/src/client.ts
|
|
20176
20187
|
class PdcClient {
|
|
20177
20188
|
baseUrl;
|
|
@@ -20239,6 +20250,9 @@ class PdcClient {
|
|
|
20239
20250
|
const data = await this.request("/api/auth/get-session");
|
|
20240
20251
|
return data?.user ? data : null;
|
|
20241
20252
|
}
|
|
20253
|
+
async signOut() {
|
|
20254
|
+
await this.post("/api/auth/sign-out");
|
|
20255
|
+
}
|
|
20242
20256
|
}
|
|
20243
20257
|
// ../core/src/login.ts
|
|
20244
20258
|
async function authenticatedClient(baseUrl, opts) {
|
|
@@ -20247,6 +20261,14 @@ async function authenticatedClient(baseUrl, opts) {
|
|
|
20247
20261
|
return null;
|
|
20248
20262
|
return new PdcClient({ baseUrl, token: cred.accessToken, fetch: opts?.fetch, clientLabel: opts?.clientLabel });
|
|
20249
20263
|
}
|
|
20264
|
+
async function logout(baseUrl, opts) {
|
|
20265
|
+
const client = await authenticatedClient(baseUrl, opts);
|
|
20266
|
+
if (!client)
|
|
20267
|
+
return "not_logged_in";
|
|
20268
|
+
const revoked = await client.signOut().then(() => true, (e) => e instanceof PdcAuthError);
|
|
20269
|
+
await clearToken(baseUrl, opts?.configDir);
|
|
20270
|
+
return revoked ? "revoked" : "local_only";
|
|
20271
|
+
}
|
|
20250
20272
|
// ../core/src/api.ts
|
|
20251
20273
|
var PAGE_SIZE = 50;
|
|
20252
20274
|
var MAX_PAGES = 20;
|
|
@@ -20554,7 +20576,7 @@ function unescapeChar(c) {
|
|
|
20554
20576
|
// package.json
|
|
20555
20577
|
var package_default = {
|
|
20556
20578
|
name: "pdc-mcp",
|
|
20557
|
-
version: "0.
|
|
20579
|
+
version: "0.7.0",
|
|
20558
20580
|
description: "Servidor MCP do PDC Deploy — opere o PDC (criar projetos, deployar, acompanhar builds) pelo seu agente de IA, com login por device code e segredos fora do chat.",
|
|
20559
20581
|
type: "module",
|
|
20560
20582
|
bin: { "pdc-mcp": "dist/index.js" },
|
|
@@ -20654,10 +20676,11 @@ class PdcSession {
|
|
|
20654
20676
|
openUrl: code.verification_uri_complete,
|
|
20655
20677
|
expiresAt: Date.now() + code.expires_in * 1000,
|
|
20656
20678
|
error: null,
|
|
20657
|
-
done: false
|
|
20679
|
+
done: false,
|
|
20680
|
+
abort: new AbortController
|
|
20658
20681
|
};
|
|
20659
20682
|
this.pending = pending;
|
|
20660
|
-
pollForToken(code, flowOpts).then(async (token) => {
|
|
20683
|
+
pollForToken(code, { ...flowOpts, signal: pending.abort.signal }).then(async (token) => {
|
|
20661
20684
|
await saveToken(this.opts.baseUrl, {
|
|
20662
20685
|
accessToken: token.accessToken,
|
|
20663
20686
|
tokenType: token.tokenType,
|
|
@@ -20675,6 +20698,15 @@ class PdcSession {
|
|
|
20675
20698
|
expiresInMinutes: Math.round(code.expires_in / 60)
|
|
20676
20699
|
};
|
|
20677
20700
|
}
|
|
20701
|
+
async logout() {
|
|
20702
|
+
this.pending?.abort.abort();
|
|
20703
|
+
this.pending = null;
|
|
20704
|
+
return logout(this.opts.baseUrl, {
|
|
20705
|
+
fetch: this.opts.fetch,
|
|
20706
|
+
configDir: this.opts.configDir,
|
|
20707
|
+
clientLabel: `pdc-mcp/${MCP_VERSION}`
|
|
20708
|
+
});
|
|
20709
|
+
}
|
|
20678
20710
|
async hasToken() {
|
|
20679
20711
|
return await loadToken(this.opts.baseUrl, this.opts.configDir) != null;
|
|
20680
20712
|
}
|
|
@@ -21005,6 +21037,11 @@ async function runLinked(fn) {
|
|
|
21005
21037
|
return failFrom(e);
|
|
21006
21038
|
}
|
|
21007
21039
|
}
|
|
21040
|
+
var LOGOUT_MESSAGE = {
|
|
21041
|
+
revoked: "Sessão encerrada. Para entrar de novo, use pdc_auth_status.",
|
|
21042
|
+
local_only: "Token apagado desta máquina, mas o servidor não confirmou o fim da sessão: ela pode valer até expirar.",
|
|
21043
|
+
not_logged_in: "Não havia login ativo nesta máquina."
|
|
21044
|
+
};
|
|
21008
21045
|
function createPdcMcpServer(opts) {
|
|
21009
21046
|
const session = new PdcSession(opts);
|
|
21010
21047
|
const server = new McpServer({ name: "pdc-deploy", version: MCP_VERSION }, { instructions: URL_DISPLAY_RULE });
|
|
@@ -21059,6 +21096,13 @@ function createPdcMcpServer(opts) {
|
|
|
21059
21096
|
opened: await openOnce(status.openUrl)
|
|
21060
21097
|
};
|
|
21061
21098
|
}));
|
|
21099
|
+
server.registerTool("pdc_logout", {
|
|
21100
|
+
description: "Sai da conta do PDC nesta máquina (vale para todos os agentes e terminais dela). Só quando o usuário " + "pedir; depois, não chame pdc_auth_status sem ele querer entrar de novo: ela inicia outro login.",
|
|
21101
|
+
inputSchema: {}
|
|
21102
|
+
}, () => run(async () => {
|
|
21103
|
+
const result = await session.logout();
|
|
21104
|
+
return { result, message: LOGOUT_MESSAGE[result] };
|
|
21105
|
+
}));
|
|
21062
21106
|
server.registerTool("pdc_check_update", {
|
|
21063
21107
|
description: "Há versão nova do MCP no npm? Devolve { current, latest, updateAvailable }; se houver, avise o usuário " + "com a instrução de atualização.",
|
|
21064
21108
|
inputSchema: {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pdc-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Servidor MCP do PDC Deploy — opere o PDC (criar projetos, deployar, acompanhar builds) pelo seu agente de IA, com login por device code e segredos fora do chat.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": { "pdc-mcp": "dist/index.js" },
|