keystone-relation-mcp 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vamp-pire
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+ import { resolve } from "node:path";
3
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
5
+ import { z } from "zod";
6
+ import { applyTrace, beforeEdit, buildCallGraphCached, loadTrace, checkFailed, diffSnapshots, explain, findRelation, isTestFor, findUnits, impactedFiles, loadProject, loadStore, parseAssignments, makeSnapshot, proposeChange, renderGraphDiff, renderMap, runCheck, saveStore, selectTests, snapshotAtRef, } from "keystone-relation-core";
7
+ const root = resolve(process.env.KEYSTONE_ROOT ?? process.cwd());
8
+ const text = (t) => ({ content: [{ type: "text", text: t }] });
9
+ /** 호출 그래프 + (있으면) 실행 기록 */
10
+ const callsOf = (files) => { const c = buildCallGraphCached(root, files).graph; const t = loadTrace(root); if (t)
11
+ applyTrace(c, t); return c; };
12
+ const server = new McpServer({ name: "keystone", version: "0.0.0" });
13
+ server.registerTool("keystone_map", { description: "프로젝트 구조 지도(모듈, 경계 규칙, pinned/free 영역)를 반환한다. 코드를 수정하기 전에 먼저 호출해 구조를 파악하는 용도." }, async () => { const p = loadProject(root); return text(renderMap(p.config, p.graph)); });
14
+ server.registerTool("keystone_check", {
15
+ description: "수정하려는 파일들이 pinned(바뀌면 안 됨) 영역인지, 경계 규칙을 위반하는지 검사한다. 파일을 고치기 전에 호출할 것.",
16
+ inputSchema: { files: z.array(z.string()).describe("프로젝트 루트 기준 상대경로") },
17
+ }, async ({ files }) => {
18
+ const p = loadProject(root);
19
+ const res = runCheck(p.config, p.graph, files, { onlyFiles: files });
20
+ // 계획 단계의 파일이라 base 비교 없이 보수적으로 판정한다 (pin 영역 파일 = 위반)
21
+ return text(JSON.stringify({ ok: !checkFailed(res), ...res }, null, 2));
22
+ });
23
+ server.registerTool("keystone_impacted_tests", {
24
+ description: "변경(예정) 파일의 영향을 받는 테스트 파일 목록을 반환한다.",
25
+ inputSchema: { files: z.array(z.string()).describe("프로젝트 루트 기준 상대경로") },
26
+ }, async ({ files }) => {
27
+ const p = loadProject(root);
28
+ const sel = selectTests(p.config, p.graph, files);
29
+ return text(JSON.stringify({ impacted: [...impactedFiles(p.graph, files)].sort(), ...sel }, null, 2));
30
+ });
31
+ server.registerTool("keystone_before_edit", {
32
+ description: "코드를 고치기 '직전'에 호출하세요. 대상 함수/파일의 직접 호출자, 영향받는 테스트, pinned/불변조건/관계 카드, 추정 연결, 시그니처를 바꿀 때 함께 고쳐야 할 곳을 짧게 알려 줍니다.",
33
+ inputSchema: { target: z.string().describe("고치려는 함수 이름/id 또는 파일 경로") },
34
+ }, async ({ target }) => { const p = loadProject(root); return text(beforeEdit(callsOf(p.graph.files), p.config, loadStore(root), target)); });
35
+ server.registerTool("keystone_explain", {
36
+ description: "파일 또는 함수를 이해하기 위한 설명: 누가 부르나/무엇을 부르나/영향 범위/대상을 확정하지 못한 호출/pinned·불변조건/관계 카드. 코드를 고치기 전에 영향 범위를 파악하는 용도.",
37
+ inputSchema: { target: z.string().describe("프로젝트 루트 기준 파일 경로 또는 함수 이름/id (예: src/pricing/total.ts#total)") },
38
+ }, async ({ target }) => { const p = loadProject(root); return text(explain(callsOf(p.graph.files), p.graph, p.config, loadStore(root), target)); });
39
+ server.registerTool("keystone_callers", {
40
+ description: "함수의 호출자(누가 이 함수를 부르거나 참조하나)와 피호출자를 반환한다. certain=false는 '그럴 수 있음'(인터페이스 구현체 후보 등).",
41
+ inputSchema: { target: z.string().describe("함수 이름 또는 id") },
42
+ }, async ({ target }) => {
43
+ const p = loadProject(root);
44
+ const calls = callsOf(p.graph.files);
45
+ return text(JSON.stringify(findUnits(calls, target).map((id) => ({
46
+ id, callers: calls.callers.get(id), callees: calls.callees.get(id), unresolved: calls.unresolved.filter((u) => u.from === id),
47
+ })), null, 2));
48
+ });
49
+ server.registerTool("keystone_relations", {
50
+ description: "저장된 관계 카드(유형/하는 것/중요도/바꿔도 되나/지켜주는 테스트)를 조회한다. unit을 주면 그 함수와 관련된 카드만.",
51
+ inputSchema: { unit: z.string().optional().describe("함수 id 일부 (생략하면 전체)") },
52
+ }, async ({ unit }) => {
53
+ const rels = loadStore(root).relations.filter((r) => !unit || r.id.toLowerCase().includes(unit.toLowerCase()));
54
+ return text(JSON.stringify(rels, null, 2));
55
+ });
56
+ server.registerTool("keystone_propose_relation", {
57
+ description: "관계 카드의 변경을 '제안'으로만 남긴다. 적용되지 않으며 사람이 승인해야 반영된다. pinned를 free로 바꾸는 등의 변경도 에이전트가 직접 할 수 없다.",
58
+ inputSchema: {
59
+ id: z.string().describe("관계 id 또는 일부"),
60
+ changes: z.array(z.string()).describe("key=value 목록 (type, does, importance, mutability, notes)"),
61
+ note: z.string().optional().describe("제안 이유"),
62
+ },
63
+ }, async ({ id, changes, note }) => {
64
+ const store = loadStore(root);
65
+ const r = findRelation(store, id);
66
+ proposeChange(r, "mcp-agent", parseAssignments(changes), note ?? "");
67
+ saveStore(root, store);
68
+ return text(`제안으로 저장됨(적용되지 않음): ${r.id}\n${JSON.stringify(r.proposal)}`);
69
+ });
70
+ server.registerTool("keystone_graph_diff", {
71
+ description: "기준(git ref, 기본 HEAD)과 현재 작업 폴더의 호출 관계를 비교한다: 사라진 관계 / 새로 생긴 관계(경계 규칙 위반 표시) / 이름 변경 후보. 관계 카드가 달린 관계는 이름·보호 수준을 같이 보여준다. 코드를 고친 뒤 의도하지 않은 관계 변화가 없는지 확인하는 용도.",
72
+ inputSchema: { base: z.string().optional().describe("비교 기준 git ref (기본 HEAD)") },
73
+ }, async ({ base }) => {
74
+ const p = loadProject(root);
75
+ const d = diffSnapshots(snapshotAtRef(root, base ?? "HEAD"), makeSnapshot(root, "작업 폴더"), { config: p.config, store: loadStore(root), isTest: isTestFor(p.config) });
76
+ return text(renderGraphDiff(d));
77
+ });
78
+ await server.connect(new StdioServerTransport());
package/package.json CHANGED
@@ -1,6 +1,47 @@
1
- {
2
- "name": "keystone-relation-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
1
+ {
2
+ "name": "keystone-relation-mcp",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "bin": {
6
+ "keystone-mcp": "dist/index.js"
7
+ },
8
+ "dependencies": {
9
+ "@modelcontextprotocol/sdk": "^1.32.2",
10
+ "keystone-relation-core": "^0.1.0",
11
+ "zod": "^4.0.0"
12
+ },
13
+ "license": "MIT",
14
+ "engines": {
15
+ "node": ">=20"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "keywords": [
21
+ "code-relations",
22
+ "call-graph",
23
+ "impact-analysis",
24
+ "test-selection",
25
+ "typescript",
26
+ "javascript",
27
+ "mcp",
28
+ "claude-code"
29
+ ],
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "description": "MCP server for keystone-relation: lets AI agents ask who calls what and what a change affects.",
34
+ "scripts": {
35
+ "prepublishOnly": "cd ../.. && npm run build"
36
+ },
37
+ "author": "Vamp-pire",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/Vamp-pire/keystone-relation.git",
41
+ "directory": "packages/mcp"
42
+ },
43
+ "homepage": "https://github.com/Vamp-pire/keystone-relation#readme",
44
+ "bugs": {
45
+ "url": "https://github.com/Vamp-pire/keystone-relation/issues"
46
+ }
47
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.