microservice-kg 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
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.
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # microservice-kg
2
+
3
+ `microservice-kg` builds a consolidated knowledge graph for a directory containing many services.
4
+
5
+ It is designed for multi-repo microservice workspaces where static code reasoning needs to happen at two levels at once:
6
+
7
+ - service-to-service dependencies
8
+ - class and method evidence behind each dependency
9
+
10
+ The first version focuses on Java/Spring microservices and produces:
11
+
12
+ - service inventory
13
+ - HTTP provider endpoints
14
+ - HTTP client edges via `@FeignClient`
15
+ - method-level evidence for each cross-service edge
16
+ - in-service class and method interaction edges
17
+
18
+ ## Why this exists
19
+
20
+ Tools like GitNexus are strong inside a single repo. This project adds a service-aware layer on top of a multi-repo workspace so you can answer:
21
+
22
+ - which services call which other services
23
+ - which class and method create that dependency
24
+ - which controller method receives the traffic on the target side
25
+
26
+ That becomes valuable when a change crosses service boundaries and code search alone is not enough.
27
+
28
+ ## Why this is useful for agentic coding
29
+
30
+ Agentic coding systems are good at editing code, but they often lack a durable architecture view across many services.
31
+
32
+ That creates a predictable failure mode:
33
+
34
+ - the agent finds one caller and assumes it is the only caller
35
+ - the agent edits one repo without seeing the upstream or downstream service contract
36
+ - the agent invents likely service relationships that are not actually present in code
37
+
38
+ `microservice-kg` reduces that failure mode by turning service dependencies into queryable graph data.
39
+
40
+ With this graph, an agent can:
41
+
42
+ - list all logical services in a workspace
43
+ - inspect incoming and outgoing dependencies of a service
44
+ - inspect the exact edge between two services
45
+ - find paths between services
46
+ - compute service-level blast radius before changing a contract
47
+
48
+ ## How this helps avoid hallucination
49
+
50
+ This project does not try to "guess" architecture from naming alone. It anchors graph edges in code evidence:
51
+
52
+ - Spring controllers and request mappings define provider endpoints
53
+ - Feign clients define outbound service calls
54
+ - method-level call-site inference identifies which class and method actually trigger a cross-service dependency
55
+
56
+ That means an agent can answer:
57
+
58
+ - "Does service A really call service B?"
59
+ - "Which method does it call?"
60
+ - "Who in the source repo triggers that call?"
61
+
62
+ with evidence instead of speculation.
63
+
64
+ This does not eliminate hallucination entirely, but it narrows the space in which an agent has to infer behavior.
65
+
66
+ ## Usage
67
+
68
+ ```bash
69
+ node src/cli.mjs analyze /path/to/workspace
70
+ ```
71
+
72
+ Optional output directory:
73
+
74
+ ```bash
75
+ node src/cli.mjs analyze /path/to/workspace --output /path/to/output
76
+ ```
77
+
78
+ The analyzer writes:
79
+
80
+ - `service-graph.json`
81
+ - `summary.md`
82
+
83
+ ## Example workflow
84
+
85
+ Analyze a workspace:
86
+
87
+ ```bash
88
+ node src/cli.mjs analyze /Users/me/workspace/services
89
+ ```
90
+
91
+ Export a service-level Obsidian vault:
92
+
93
+ ```bash
94
+ node src/export-obsidian.mjs /Users/me/workspace/services/.microservice-kg/service-graph.json /Users/me/workspace/services/obsidian-vault
95
+ ```
96
+
97
+ ## MCP server
98
+
99
+ The project also exposes the generated graph over MCP so coding agents can query service dependencies while making changes.
100
+
101
+ Run the server against the default local graph:
102
+
103
+ ```bash
104
+ node src/mcp-server.mjs
105
+ ```
106
+
107
+ Or point it at a specific graph artifact:
108
+
109
+ ```bash
110
+ MICROSERVICE_KG_GRAPH=/path/to/service-graph.json node src/mcp-server.mjs
111
+ ```
112
+
113
+ Available MCP tools:
114
+
115
+ - `analyze_workspace`
116
+ - `list_services`
117
+ - `service_context`
118
+ - `edge_details`
119
+ - `dependency_path`
120
+ - `service_impact`
121
+
122
+ For `dependency_path` and `service_impact`, `maxDepth` is optional. If omitted, traversal walks as deep as the currently loaded logical service graph allows.
123
+
124
+ Example MCP registration:
125
+
126
+ ```bash
127
+ codex mcp add microservice-kg -- env MICROSERVICE_KG_GRAPH=/path/to/service-graph.json node /path/to/microservice-kg/src/mcp-server.mjs
128
+ ```
129
+
130
+ Example questions an agent can ask through MCP:
131
+
132
+ - "List all services in this workspace."
133
+ - "Show the incoming and outgoing dependencies of a service."
134
+ - "Explain the edge between two services with method-level evidence."
135
+ - "Find the dependency path from one service to another."
136
+ - "Show the downstream impact of changing a service."
137
+
138
+ ## Current scope
139
+
140
+ - Java/Spring service discovery
141
+ - `@RestController` and `@RequestMapping` endpoint extraction
142
+ - `@FeignClient` extraction
143
+ - config-backed path and URL resolution from `application*.properties|yml|yaml`
144
+ - field-based method call inference inside Java classes
145
+ - Obsidian export for service-level graph visualization
146
+ - MCP server for editor and coding-agent integration
147
+
148
+ ## Current limitations
149
+
150
+ - HTTP edges currently focus on `@FeignClient`
151
+ - `WebClient`, `RestTemplate`, Kafka, gRPC, and async messaging are not fully modeled yet
152
+ - service identity normalization is pragmatic, not perfect
153
+ - large workspaces may need a future incremental indexer rather than full rescans
154
+
155
+ ## Roadmap
156
+
157
+ - `WebClient` and `RestTemplate`
158
+ - Kafka producers and consumers
159
+ - gRPC
160
+ - runtime reconciliation with OpenTelemetry service graphs
161
+ - graph UI and interactive exploration
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "microservice-kg",
3
+ "version": "0.1.0",
4
+ "description": "Consolidated microservice knowledge graph generator for multi-repo workspaces, with MCP support for agentic coding",
5
+ "type": "module",
6
+ "files": [
7
+ "src",
8
+ "README.md",
9
+ "LICENSE"
10
+ ],
11
+ "bin": {
12
+ "microservice-kg": "./src/cli.mjs",
13
+ "microservice-kg-mcp": "./src/mcp-server.mjs"
14
+ },
15
+ "scripts": {
16
+ "analyze": "node ./src/cli.mjs analyze",
17
+ "start": "node ./src/cli.mjs",
18
+ "mcp": "node ./src/mcp-server.mjs",
19
+ "pack:check": "npm pack --dry-run"
20
+ },
21
+ "keywords": [
22
+ "microservices",
23
+ "knowledge-graph",
24
+ "architecture",
25
+ "java",
26
+ "spring",
27
+ "mcp",
28
+ "agentic-coding",
29
+ "dependency-graph",
30
+ "static-analysis"
31
+ ],
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/pawarss1/microservice-kg.git"
36
+ },
37
+ "bugs": {
38
+ "url": "https://github.com/pawarss1/microservice-kg/issues"
39
+ },
40
+ "homepage": "https://github.com/pawarss1/microservice-kg#readme",
41
+ "engines": {
42
+ "node": ">=20"
43
+ }
44
+ }