GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — 2.1.0 — vault CLI 에 MCP 를 붙인다 · datamaker/vault@9c667d8

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/cli
    • package.json
    • src
      • commands
        • mcp.ts
      • index.ts
      • version.ts
  • package-lock.json
  • package.json
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/cli/package.json‎

Copy file name to clipboardExpand all lines: apps/cli/package.json
+9-7Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@datasee/vault",
3-
"version": "1.1.2",
3+
"version": "1.2.0",
44
"description": "Secret Vault CLI - Doppler alternative for managing secrets from command line",
55
"keywords": [
66
"secrets",
@@ -40,18 +40,20 @@
4040
"node": ">=18.0.0"
4141
},
4242
"dependencies": {
43-
"commander": "^11.1.0",
43+
"@modelcontextprotocol/sdk": "^1.30.0",
4444
"axios": "^1.6.2",
4545
"chalk": "^4.1.2",
46-
"ora": "^5.4.1",
46+
"commander": "^11.1.0",
4747
"conf": "^10.2.0",
48+
"dotenv": "^16.3.1",
4849
"inquirer": "^8.2.6",
49-
"dotenv": "^16.3.1"
50+
"ora": "^5.4.1",
51+
"zod": "^4.5.4"
5052
},
5153
"devDependencies": {
52-
"@types/node": "^20.10.0",
5354
"@types/inquirer": "^8.2.10",
54-
"typescript": "^5.3.3",
55-
"ts-node": "^10.9.2"
55+
"@types/node": "^20.10.0",
56+
"ts-node": "^10.9.2",
57+
"typescript": "^5.3.3"
5658
}
5759
}
Collapse file

‎apps/cli/src/commands/mcp.ts‎

Copy file name to clipboard
+134Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
import { Command } from 'commander';
2+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4+
import { z } from 'zod';
5+
import { getClient } from '../api';
6+
import { getApiUrl, getToken, getProject, getEnvironment } from '../config';
7+
import { VERSION } from '../version';
8+
9+
/**
10+
* MCP 서버 모드. Claude 같은 도구가 vault 를 다룰 수 있게 한다.
11+
*
12+
* **시크릿 값은 내주지 않는다.** MCP 로 값을 돌려주면 그 값이 AI 컨텍스트와
13+
* 대화 기록에 그대로 남는다 — 시크릿 관리 도구에서 이건 유출이다. 여기서는
14+
* 키·설명·버전·수정 이력 같은 메타데이터만 다루고, 값이 필요하면 사람이
15+
* `vault run -- <명령>` 이나 `vault export` 로 프로세스 환경에 주입한다.
16+
* 값은 그 프로세스 안에만 있고 로그에는 안 남는다.
17+
*/
18+
export function mcpCommand(): Command {
19+
return new Command('mcp')
20+
.description('Run as an MCP stdio server (metadata only — never returns secret values)')
21+
.action(async () => {
22+
const server = new McpServer({ name: 'vault', version: VERSION });
23+
registerTools(server);
24+
await server.connect(new StdioServerTransport());
25+
});
26+
}
27+
28+
const ok = (data: unknown) => ({
29+
content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }],
30+
});
31+
const fail = (message: string) => ({
32+
content: [{ type: 'text' as const, text: message }],
33+
isError: true,
34+
});
35+
36+
async function get<T>(url: string): Promise<T> {
37+
const { data } = await getClient().get<T>(url);
38+
return data;
39+
}
40+
41+
function registerTools(server: McpServer) {
42+
server.tool(
43+
'vault_status',
44+
'로그인 상태와 접속 중인 서버, 기본 프로젝트·환경을 본다.',
45+
{},
46+
async () => {
47+
if (!getToken()) {
48+
return ok({ apiUrl: getApiUrl(), loggedIn: false, hint: '`vault login` 으로 로그인하세요.' });
49+
}
50+
try {
51+
const me = await get<{ email: string; name?: string }>('/auth/me');
52+
return ok({
53+
apiUrl: getApiUrl(),
54+
loggedIn: true,
55+
user: me,
56+
defaultProject: getProject() ?? null,
57+
defaultEnvironment: getEnvironment() ?? null,
58+
});
59+
} catch {
60+
return ok({ apiUrl: getApiUrl(), loggedIn: false, hint: '세션이 만료됐습니다. `vault login`.' });
61+
}
62+
}
63+
);
64+
65+
server.tool('vault_teams', '팀 목록.', {}, async () => ok(await get('/teams')));
66+
67+
server.tool(
68+
'vault_team_members',
69+
'팀 구성원과 역할. 누가 어떤 시크릿에 접근할 수 있는지 파악할 때 쓴다.',
70+
{ teamId: z.string() },
71+
async ({ teamId }) => ok(await get(`/teams/${teamId}/members`))
72+
);
73+
74+
server.tool(
75+
'vault_team_activity',
76+
'팀의 최근 활동 기록 — 누가 언제 무엇을 바꿨나.',
77+
{ teamId: z.string() },
78+
async ({ teamId }) => ok(await get(`/teams/${teamId}/activity`))
79+
);
80+
81+
server.tool('vault_projects', '프로젝트 목록.', {}, async () => ok(await get('/projects')));
82+
83+
server.tool(
84+
'vault_environments',
85+
'프로젝트의 환경 목록(dev/staging/production 등).',
86+
{ projectId: z.string() },
87+
async ({ projectId }) => ok(await get(`/projects/${projectId}/environments`))
88+
);
89+
90+
server.tool(
91+
'vault_secrets_list',
92+
'환경에 어떤 시크릿 키가 있는지 본다. **값은 돌려주지 않는다** — 키·설명·버전·수정 시각만.',
93+
{ environmentId: z.string() },
94+
async ({ environmentId }) => {
95+
// values=true 를 절대 붙이지 않는다. 붙이면 값이 그대로 딸려 온다.
96+
const secrets = await get<any[]>(`/environments/${environmentId}/secrets`);
97+
return ok(
98+
secrets.map((s) => ({
99+
key: s.key,
100+
description: s.description ?? null,
101+
isSensitive: s.is_sensitive ?? s.isSensitive ?? null,
102+
version: s.version,
103+
updatedAt: s.updated_at ?? s.updatedAt,
104+
}))
105+
);
106+
}
107+
);
108+
109+
server.tool(
110+
'vault_secret_history',
111+
'시크릿 한 건의 변경 이력(값 제외). secretId 는 vault_secrets_list 로 얻는다.',
112+
{ secretId: z.string() },
113+
async ({ secretId }) => ok(await get(`/secrets/${secretId}/history`))
114+
);
115+
116+
server.tool(
117+
'vault_secret_value',
118+
'시크릿 값 읽기 — 이 도구는 값을 돌려주지 않는다. 왜 그런지 설명한다.',
119+
{ key: z.string().optional() },
120+
async ({ key }) =>
121+
fail(
122+
[
123+
`${key ? `"${key}" 의 ` : ''}값은 MCP 로 내주지 않습니다.`,
124+
'',
125+
'MCP 응답은 AI 컨텍스트와 대화 기록에 남습니다. 시크릿 값이 거기 들어가면',
126+
'지울 수 없는 곳에 평문으로 복사되는 셈입니다.',
127+
'',
128+
'값이 필요하면 사람이 터미널에서 쓰세요:',
129+
' vault run -- <명령> 값을 그 프로세스 환경에만 주입',
130+
' vault secrets get <키> 화면에 직접 출력',
131+
].join('\n')
132+
)
133+
);
134+
}
Collapse file

‎apps/cli/src/index.ts‎

Copy file name to clipboardExpand all lines: apps/cli/src/index.ts
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
deleteSecretCommand,
1515
} from './commands/secrets';
1616
import { exportCommand } from './commands/export';
17+
import { mcpCommand } from './commands/mcp';
1718

1819
const packageJson = JSON.parse(
1920
readFileSync(join(__dirname, '..', 'package.json'), 'utf-8')
@@ -113,4 +114,6 @@ secrets.action(() => {
113114
listSecretsCommand({});
114115
});
115116

117+
program.addCommand(mcpCommand());
118+
116119
program.parse();
Collapse file

‎apps/cli/src/version.ts‎

Copy file name to clipboard
+19Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { readFileSync } from 'node:fs';
2+
import path from 'node:path';
3+
4+
/**
5+
* package.json 에서 버전을 읽는다. 문자열로 박아 두면 릴리스할 때 어긋난다.
6+
*/
7+
function read(): string {
8+
for (const rel of ['../package.json', '../../package.json']) {
9+
try {
10+
const pkg = JSON.parse(readFileSync(path.join(__dirname, rel), 'utf8'));
11+
if (pkg?.name === '@datasee/vault' && pkg.version) return pkg.version as string;
12+
} catch {
13+
/* 다음 후보 */
14+
}
15+
}
16+
return '0.0.0';
17+
}
18+
19+
export const VERSION = read();

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.