universal-json-agent-mcp 0.1.0__tar.gz

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.
Files changed (50) hide show
  1. universal_json_agent_mcp-0.1.0/.env.example +7 -0
  2. universal_json_agent_mcp-0.1.0/.gitignore +46 -0
  3. universal_json_agent_mcp-0.1.0/.vscode/mcp.json +16 -0
  4. universal_json_agent_mcp-0.1.0/LICENSE +21 -0
  5. universal_json_agent_mcp-0.1.0/PKG-INFO +317 -0
  6. universal_json_agent_mcp-0.1.0/README.md +289 -0
  7. universal_json_agent_mcp-0.1.0/plan1.md +273 -0
  8. universal_json_agent_mcp-0.1.0/plan3.md +373 -0
  9. universal_json_agent_mcp-0.1.0/pyproject.toml +52 -0
  10. universal_json_agent_mcp-0.1.0/sample.json +715 -0
  11. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/__init__.py +3 -0
  12. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/__main__.py +5 -0
  13. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/server.py +667 -0
  14. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/store.py +227 -0
  15. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/tools/__init__.py +0 -0
  16. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/tools/advanced_query.py +230 -0
  17. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/tools/aggregate.py +176 -0
  18. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/tools/explore.py +185 -0
  19. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/tools/export.py +140 -0
  20. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/tools/introspect.py +114 -0
  21. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/tools/load.py +67 -0
  22. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/tools/query.py +199 -0
  23. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/tools/stats.py +116 -0
  24. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/tools/transform.py +244 -0
  25. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/utils/__init__.py +0 -0
  26. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/utils/path_resolver.py +78 -0
  27. universal_json_agent_mcp-0.1.0/src/universal_json_agent_mcp/utils/truncation.py +82 -0
  28. universal_json_agent_mcp-0.1.0/tests/__init__.py +0 -0
  29. universal_json_agent_mcp-0.1.0/tests/conftest.py +300 -0
  30. universal_json_agent_mcp-0.1.0/tests/test_path_resolver.py +129 -0
  31. universal_json_agent_mcp-0.1.0/tests/test_server.py +438 -0
  32. universal_json_agent_mcp-0.1.0/tests/test_store.py +332 -0
  33. universal_json_agent_mcp-0.1.0/tests/test_tools/__init__.py +0 -0
  34. universal_json_agent_mcp-0.1.0/tests/test_tools/test_advanced_query.py +298 -0
  35. universal_json_agent_mcp-0.1.0/tests/test_tools/test_aggregate.py +331 -0
  36. universal_json_agent_mcp-0.1.0/tests/test_tools/test_explore.py +327 -0
  37. universal_json_agent_mcp-0.1.0/tests/test_tools/test_export.py +251 -0
  38. universal_json_agent_mcp-0.1.0/tests/test_tools/test_introspect.py +160 -0
  39. universal_json_agent_mcp-0.1.0/tests/test_tools/test_load.py +64 -0
  40. universal_json_agent_mcp-0.1.0/tests/test_tools/test_query.py +353 -0
  41. universal_json_agent_mcp-0.1.0/tests/test_tools/test_stats.py +134 -0
  42. universal_json_agent_mcp-0.1.0/tests/test_tools/test_transform.py +443 -0
  43. universal_json_agent_mcp-0.1.0/tests/test_truncation.py +121 -0
  44. universal_json_agent_mcp-0.1.0/web/__init__.py +7 -0
  45. universal_json_agent_mcp-0.1.0/web/agent.py +160 -0
  46. universal_json_agent_mcp-0.1.0/web/app.py +189 -0
  47. universal_json_agent_mcp-0.1.0/web/config.py +35 -0
  48. universal_json_agent_mcp-0.1.0/web/requirements.txt +12 -0
  49. universal_json_agent_mcp-0.1.0/web/run.py +40 -0
  50. universal_json_agent_mcp-0.1.0/web/tools.py +425 -0
@@ -0,0 +1,7 @@
1
+ # Copy this to .env and fill in your key.
2
+
3
+ # Required — get one at https://openrouter.ai/keys
4
+ OPENROUTER_API_KEY=sk-or-v1-your-key-here
5
+
6
+ # Optional — override the default model
7
+ # OPENROUTER_MODEL=openai/gpt-4o-mini
@@ -0,0 +1,46 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ *.egg-info/
7
+ *.egg
8
+ dist/
9
+ build/
10
+ *.whl
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ env/
16
+
17
+ # Environment variables (contains secrets)
18
+ .env
19
+
20
+ # IDE / Editor
21
+ .vscode/*
22
+ !.vscode/mcp.json
23
+ .idea/
24
+ *.swp
25
+ *.swo
26
+ *~
27
+
28
+ # Testing / Coverage
29
+ .pytest_cache/
30
+ htmlcov/
31
+ .coverage
32
+ .coverage.*
33
+ coverage.xml
34
+
35
+ # OS files
36
+ .DS_Store
37
+ Thumbs.db
38
+
39
+ # uv
40
+ uv.lock
41
+
42
+ # Temp uploads from web server
43
+ /tmp/json_agent_uploads/
44
+
45
+ # Misc
46
+ *.log
@@ -0,0 +1,16 @@
1
+ {
2
+ "servers": {
3
+ "universal-json-agent": {
4
+ "type": "stdio",
5
+ "command": "uv",
6
+ "args": [
7
+ "--directory",
8
+ "${workspaceFolder}",
9
+ "run",
10
+ "python",
11
+ "-m",
12
+ "universal_json_agent_mcp"
13
+ ]
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gautam Vhavle
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,317 @@
1
+ Metadata-Version: 2.4
2
+ Name: universal-json-agent-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for advanced JSON parsing — load, query, aggregate, transform any JSON file from GitHub Copilot, Claude, Cursor, or any MCP client.
5
+ Project-URL: Homepage, https://github.com/GautamVhavle/universal-json-agent
6
+ Project-URL: Repository, https://github.com/GautamVhavle/universal-json-agent
7
+ Project-URL: Issues, https://github.com/GautamVhavle/universal-json-agent/issues
8
+ Author: Gautam Vhavle
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Keywords: agent,copilot,json,jsonpath,mcp,parsing
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Requires-Python: >=3.11
20
+ Requires-Dist: ijson>=3.2.0
21
+ Requires-Dist: jsonpath-ng>=1.6.0
22
+ Requires-Dist: mcp[cli]>=1.0.0
23
+ Requires-Dist: pydantic>=2.0.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
26
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
27
+ Description-Content-Type: text/markdown
28
+
29
+ # Universal JSON Agent MCP
30
+
31
+ An MCP server for parsing, querying, and analysing JSON files — installable from PyPI.
32
+
33
+ ```bash
34
+ pip install universal-json-agent-mcp
35
+ ```
36
+
37
+ 26 tools for loading, exploring, querying, aggregating, transforming, and exporting JSON — usable from **GitHub Copilot**, **Claude Desktop**, **Cursor**, or any MCP client.
38
+
39
+ ---
40
+
41
+ ## Table of Contents
42
+
43
+ - [Quick Start](#quick-start)
44
+ - [MCP Client Configuration](#mcp-client-configuration)
45
+ - [Web API Server (Optional)](#web-api-server-optional)
46
+ - [Tools Reference](#tools-reference)
47
+ - [Development](#development)
48
+ - [Project Structure](#project-structure)
49
+ - [Testing](#testing)
50
+ - [Configuration](#configuration)
51
+ - [Troubleshooting](#troubleshooting)
52
+
53
+ ---
54
+
55
+ ## Quick Start
56
+
57
+ ### Install
58
+
59
+ ```bash
60
+ pip install universal-json-agent-mcp
61
+ # or
62
+ uv add universal-json-agent-mcp
63
+ ```
64
+
65
+ ### Run
66
+
67
+ ```bash
68
+ universal-json-agent-mcp
69
+ # or
70
+ python -m universal_json_agent_mcp
71
+ ```
72
+
73
+ The server starts on **stdio** — connect any MCP client to it.
74
+
75
+ ---
76
+
77
+ ## MCP Client Configuration
78
+
79
+ ### VS Code / GitHub Copilot
80
+
81
+ Add to `.vscode/mcp.json` in your workspace:
82
+
83
+ ```json
84
+ {
85
+ "servers": {
86
+ "universal-json-agent": {
87
+ "type": "stdio",
88
+ "command": "universal-json-agent-mcp"
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ Or use `uvx` (no install needed):
95
+
96
+ ```json
97
+ {
98
+ "servers": {
99
+ "universal-json-agent": {
100
+ "type": "stdio",
101
+ "command": "uvx",
102
+ "args": ["universal-json-agent-mcp"]
103
+ }
104
+ }
105
+ }
106
+ ```
107
+
108
+ ### Claude Desktop
109
+
110
+ Add to `claude_desktop_config.json`:
111
+
112
+ ```json
113
+ {
114
+ "mcpServers": {
115
+ "universal-json-agent": {
116
+ "command": "universal-json-agent-mcp"
117
+ }
118
+ }
119
+ }
120
+ ```
121
+
122
+ ### Cursor
123
+
124
+ Add to Cursor's MCP settings:
125
+
126
+ ```json
127
+ {
128
+ "mcpServers": {
129
+ "universal-json-agent": {
130
+ "command": "universal-json-agent-mcp"
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ ### Example prompts
137
+
138
+ Once connected, ask natural-language questions in your AI chat:
139
+
140
+ ```
141
+ Load the file data/orders.json and tell me what's in it
142
+ How many missions are there?
143
+ What are the codenames of all missions with status "in_progress"?
144
+ What's the total budget across all missions?
145
+ Sort missions by budget descending
146
+ Get all personnel names using JSONPath
147
+ ```
148
+
149
+ ---
150
+
151
+ ## Web API Server (Optional)
152
+
153
+ The repo also includes a standalone FastAPI + LangChain web server that wraps the same 26 tools behind a REST API. See [web/](web/) for details.
154
+
155
+ ```bash
156
+ # Install web dependencies
157
+ pip install -r web/requirements.txt
158
+
159
+ # Set your OpenRouter API key
160
+ cp .env.example .env # then edit .env
161
+
162
+ # Start the server
163
+ python -m web.run --port 8000
164
+ ```
165
+
166
+ Endpoints: `GET /health`, `POST /query` (file upload), `POST /query/path` (file on disk). Swagger UI at `/docs`.
167
+
168
+ ---
169
+
170
+ ## Tools Reference
171
+
172
+ ### Load & Manage
173
+ | Tool | Description |
174
+ |------|-------------|
175
+ | `load_json` | Load a JSON file from disk into memory |
176
+ | `list_loaded` | Show all loaded documents with metadata |
177
+ | `unload_json` | Remove a document from memory |
178
+
179
+ ### Explore
180
+ | Tool | Description |
181
+ |------|-------------|
182
+ | `get_keys` | Get keys (object) or index range (array) at a path |
183
+ | `get_value` | Retrieve the value at a path (auto-truncated at 10KB) |
184
+ | `get_type` | Return the JSON type at a path |
185
+ | `get_structure` | Schema-like skeleton showing keys and types |
186
+
187
+ ### Query
188
+ | Tool | Description |
189
+ |------|-------------|
190
+ | `jsonpath_query` | Execute a JSONPath expression (e.g. `$.users[*].email`) |
191
+ | `filter_objects` | Filter arrays by a field condition (eq, gt, lt, contains, regex…) |
192
+ | `search_text` | Recursively search all string values for a substring or regex |
193
+
194
+ ### Aggregate
195
+ | Tool | Description |
196
+ |------|-------------|
197
+ | `count` | Count items in an array or keys in an object |
198
+ | `sum_values` | Sum numeric values at a JSONPath |
199
+ | `min_max` | Get min and max of numeric values |
200
+ | `unique_values` | Get distinct values at a JSONPath |
201
+ | `value_counts` | Frequency table of values (like pandas `value_counts()`) |
202
+
203
+ ### Transform
204
+ | Tool | Description |
205
+ |------|-------------|
206
+ | `flatten` | Flatten nested objects into dot-notation key-value pairs |
207
+ | `pick_fields` | Project specific fields from array objects |
208
+ | `group_by` | Group array objects by a field value |
209
+ | `sort_by` | Sort array objects by a field |
210
+ | `sample` | Return N random items from an array |
211
+
212
+ ### Analytics
213
+ | Tool | Description |
214
+ |------|-------------|
215
+ | `describe` | Statistical summary (count, mean, std, min, max, percentiles) |
216
+ | `multi_filter` | Filter with multiple AND/OR conditions |
217
+ | `compare` | Diff two JSON values — added/removed keys, type/value changes |
218
+
219
+ ### Export
220
+ | Tool | Description |
221
+ |------|-------------|
222
+ | `export_csv` | Export an array of objects to CSV |
223
+ | `export_json` | Export a value at a path to a new JSON file |
224
+
225
+ ### Introspect
226
+ | Tool | Description |
227
+ |------|-------------|
228
+ | `distinct_paths` | List every unique leaf path in a document with types |
229
+
230
+ ---
231
+
232
+ ## Development
233
+
234
+ ```bash
235
+ # Clone and install for development
236
+ git clone https://github.com/GautamVhavle/universal-json-agent.git
237
+ cd universal-json-agent
238
+ uv sync --extra dev
239
+ ```
240
+
241
+ ---
242
+
243
+ ## Project Structure
244
+
245
+ ```
246
+ universal-json-agent/
247
+ ├── src/universal_json_agent_mcp/ # Installable MCP server package
248
+ │ ├── __init__.py
249
+ │ ├── __main__.py # python -m universal_json_agent_mcp
250
+ │ ├── server.py # MCP entry point — registers all 26 tools
251
+ │ ├── store.py # In-memory document store with metadata
252
+ │ ├── tools/
253
+ │ │ ├── load.py # load_json, list_loaded, unload_json
254
+ │ │ ├── explore.py # get_keys, get_value, get_type, get_structure
255
+ │ │ ├── query.py # jsonpath_query, filter_objects, search_text
256
+ │ │ ├── aggregate.py # count, sum_values, min_max, unique_values, value_counts
257
+ │ │ ├── transform.py # flatten, pick_fields, group_by, sort_by, sample
258
+ │ │ ├── stats.py # describe
259
+ │ │ ├── advanced_query.py # multi_filter, compare
260
+ │ │ ├── export.py # export_csv, export_json
261
+ │ │ └── introspect.py # distinct_paths
262
+ │ └── utils/
263
+ │ ├── path_resolver.py # Dot/bracket path navigation
264
+ │ └── truncation.py # Smart output capping
265
+
266
+ ├── web/ # Optional FastAPI + LangChain web server
267
+ ├── tests/ # 489 tests
268
+ ├── pyproject.toml # Package metadata (PyPI)
269
+ ├── LICENSE # MIT
270
+ └── sample.json # Example JSON file
271
+ ```
272
+
273
+ ---
274
+
275
+ ## Testing
276
+
277
+ ```bash
278
+ # Run all tests
279
+ uv run pytest
280
+
281
+ # Run with verbose output
282
+ uv run pytest -v
283
+
284
+ # Run a specific test file
285
+ uv run pytest tests/test_tools/test_aggregate.py
286
+
287
+ # Run tests matching a name pattern
288
+ uv run pytest -k "test_filter"
289
+ ```
290
+
291
+ ---
292
+
293
+ ## Configuration
294
+
295
+ ### Environment variables
296
+
297
+ | Variable | Required | Default | Description |
298
+ |----------|----------|---------|-------------|
299
+ | `OPENROUTER_API_KEY` | Yes (web only) | — | Your OpenRouter API key |
300
+ | `OPENROUTER_MODEL` | No | `openai/gpt-4o-mini` | Any model from [openrouter.ai/models](https://openrouter.ai/models) |
301
+
302
+ ### MCP server config
303
+
304
+ The MCP server requires no configuration. It's registered via `.vscode/mcp.json` and uses stdio transport.
305
+
306
+ ---
307
+
308
+ ## Troubleshooting
309
+
310
+ | Problem | Solution |
311
+ |---------|----------|
312
+ | MCP server not appearing in Copilot | Make sure `.vscode/mcp.json` exists and the workspace is open. Restart VS Code. |
313
+ | "No document loaded" errors | Call `load_json` first before querying. |
314
+ | Truncated output | Large results are capped at ~10KB. Use specific paths or filters to narrow results. |
315
+ | `OPENROUTER_API_KEY not set` | Create a `.env` file from `.env.example` and add your key. |
316
+ | 429 Too Many Requests | You're rate-limited by the model provider. Wait a moment or switch to a different model. |
317
+ | Import errors in web server | Run `uv pip install -r web/requirements.txt` to install web dependencies. |
@@ -0,0 +1,289 @@
1
+ # Universal JSON Agent MCP
2
+
3
+ An MCP server for parsing, querying, and analysing JSON files — installable from PyPI.
4
+
5
+ ```bash
6
+ pip install universal-json-agent-mcp
7
+ ```
8
+
9
+ 26 tools for loading, exploring, querying, aggregating, transforming, and exporting JSON — usable from **GitHub Copilot**, **Claude Desktop**, **Cursor**, or any MCP client.
10
+
11
+ ---
12
+
13
+ ## Table of Contents
14
+
15
+ - [Quick Start](#quick-start)
16
+ - [MCP Client Configuration](#mcp-client-configuration)
17
+ - [Web API Server (Optional)](#web-api-server-optional)
18
+ - [Tools Reference](#tools-reference)
19
+ - [Development](#development)
20
+ - [Project Structure](#project-structure)
21
+ - [Testing](#testing)
22
+ - [Configuration](#configuration)
23
+ - [Troubleshooting](#troubleshooting)
24
+
25
+ ---
26
+
27
+ ## Quick Start
28
+
29
+ ### Install
30
+
31
+ ```bash
32
+ pip install universal-json-agent-mcp
33
+ # or
34
+ uv add universal-json-agent-mcp
35
+ ```
36
+
37
+ ### Run
38
+
39
+ ```bash
40
+ universal-json-agent-mcp
41
+ # or
42
+ python -m universal_json_agent_mcp
43
+ ```
44
+
45
+ The server starts on **stdio** — connect any MCP client to it.
46
+
47
+ ---
48
+
49
+ ## MCP Client Configuration
50
+
51
+ ### VS Code / GitHub Copilot
52
+
53
+ Add to `.vscode/mcp.json` in your workspace:
54
+
55
+ ```json
56
+ {
57
+ "servers": {
58
+ "universal-json-agent": {
59
+ "type": "stdio",
60
+ "command": "universal-json-agent-mcp"
61
+ }
62
+ }
63
+ }
64
+ ```
65
+
66
+ Or use `uvx` (no install needed):
67
+
68
+ ```json
69
+ {
70
+ "servers": {
71
+ "universal-json-agent": {
72
+ "type": "stdio",
73
+ "command": "uvx",
74
+ "args": ["universal-json-agent-mcp"]
75
+ }
76
+ }
77
+ }
78
+ ```
79
+
80
+ ### Claude Desktop
81
+
82
+ Add to `claude_desktop_config.json`:
83
+
84
+ ```json
85
+ {
86
+ "mcpServers": {
87
+ "universal-json-agent": {
88
+ "command": "universal-json-agent-mcp"
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ ### Cursor
95
+
96
+ Add to Cursor's MCP settings:
97
+
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "universal-json-agent": {
102
+ "command": "universal-json-agent-mcp"
103
+ }
104
+ }
105
+ }
106
+ ```
107
+
108
+ ### Example prompts
109
+
110
+ Once connected, ask natural-language questions in your AI chat:
111
+
112
+ ```
113
+ Load the file data/orders.json and tell me what's in it
114
+ How many missions are there?
115
+ What are the codenames of all missions with status "in_progress"?
116
+ What's the total budget across all missions?
117
+ Sort missions by budget descending
118
+ Get all personnel names using JSONPath
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Web API Server (Optional)
124
+
125
+ The repo also includes a standalone FastAPI + LangChain web server that wraps the same 26 tools behind a REST API. See [web/](web/) for details.
126
+
127
+ ```bash
128
+ # Install web dependencies
129
+ pip install -r web/requirements.txt
130
+
131
+ # Set your OpenRouter API key
132
+ cp .env.example .env # then edit .env
133
+
134
+ # Start the server
135
+ python -m web.run --port 8000
136
+ ```
137
+
138
+ Endpoints: `GET /health`, `POST /query` (file upload), `POST /query/path` (file on disk). Swagger UI at `/docs`.
139
+
140
+ ---
141
+
142
+ ## Tools Reference
143
+
144
+ ### Load & Manage
145
+ | Tool | Description |
146
+ |------|-------------|
147
+ | `load_json` | Load a JSON file from disk into memory |
148
+ | `list_loaded` | Show all loaded documents with metadata |
149
+ | `unload_json` | Remove a document from memory |
150
+
151
+ ### Explore
152
+ | Tool | Description |
153
+ |------|-------------|
154
+ | `get_keys` | Get keys (object) or index range (array) at a path |
155
+ | `get_value` | Retrieve the value at a path (auto-truncated at 10KB) |
156
+ | `get_type` | Return the JSON type at a path |
157
+ | `get_structure` | Schema-like skeleton showing keys and types |
158
+
159
+ ### Query
160
+ | Tool | Description |
161
+ |------|-------------|
162
+ | `jsonpath_query` | Execute a JSONPath expression (e.g. `$.users[*].email`) |
163
+ | `filter_objects` | Filter arrays by a field condition (eq, gt, lt, contains, regex…) |
164
+ | `search_text` | Recursively search all string values for a substring or regex |
165
+
166
+ ### Aggregate
167
+ | Tool | Description |
168
+ |------|-------------|
169
+ | `count` | Count items in an array or keys in an object |
170
+ | `sum_values` | Sum numeric values at a JSONPath |
171
+ | `min_max` | Get min and max of numeric values |
172
+ | `unique_values` | Get distinct values at a JSONPath |
173
+ | `value_counts` | Frequency table of values (like pandas `value_counts()`) |
174
+
175
+ ### Transform
176
+ | Tool | Description |
177
+ |------|-------------|
178
+ | `flatten` | Flatten nested objects into dot-notation key-value pairs |
179
+ | `pick_fields` | Project specific fields from array objects |
180
+ | `group_by` | Group array objects by a field value |
181
+ | `sort_by` | Sort array objects by a field |
182
+ | `sample` | Return N random items from an array |
183
+
184
+ ### Analytics
185
+ | Tool | Description |
186
+ |------|-------------|
187
+ | `describe` | Statistical summary (count, mean, std, min, max, percentiles) |
188
+ | `multi_filter` | Filter with multiple AND/OR conditions |
189
+ | `compare` | Diff two JSON values — added/removed keys, type/value changes |
190
+
191
+ ### Export
192
+ | Tool | Description |
193
+ |------|-------------|
194
+ | `export_csv` | Export an array of objects to CSV |
195
+ | `export_json` | Export a value at a path to a new JSON file |
196
+
197
+ ### Introspect
198
+ | Tool | Description |
199
+ |------|-------------|
200
+ | `distinct_paths` | List every unique leaf path in a document with types |
201
+
202
+ ---
203
+
204
+ ## Development
205
+
206
+ ```bash
207
+ # Clone and install for development
208
+ git clone https://github.com/GautamVhavle/universal-json-agent.git
209
+ cd universal-json-agent
210
+ uv sync --extra dev
211
+ ```
212
+
213
+ ---
214
+
215
+ ## Project Structure
216
+
217
+ ```
218
+ universal-json-agent/
219
+ ├── src/universal_json_agent_mcp/ # Installable MCP server package
220
+ │ ├── __init__.py
221
+ │ ├── __main__.py # python -m universal_json_agent_mcp
222
+ │ ├── server.py # MCP entry point — registers all 26 tools
223
+ │ ├── store.py # In-memory document store with metadata
224
+ │ ├── tools/
225
+ │ │ ├── load.py # load_json, list_loaded, unload_json
226
+ │ │ ├── explore.py # get_keys, get_value, get_type, get_structure
227
+ │ │ ├── query.py # jsonpath_query, filter_objects, search_text
228
+ │ │ ├── aggregate.py # count, sum_values, min_max, unique_values, value_counts
229
+ │ │ ├── transform.py # flatten, pick_fields, group_by, sort_by, sample
230
+ │ │ ├── stats.py # describe
231
+ │ │ ├── advanced_query.py # multi_filter, compare
232
+ │ │ ├── export.py # export_csv, export_json
233
+ │ │ └── introspect.py # distinct_paths
234
+ │ └── utils/
235
+ │ ├── path_resolver.py # Dot/bracket path navigation
236
+ │ └── truncation.py # Smart output capping
237
+
238
+ ├── web/ # Optional FastAPI + LangChain web server
239
+ ├── tests/ # 489 tests
240
+ ├── pyproject.toml # Package metadata (PyPI)
241
+ ├── LICENSE # MIT
242
+ └── sample.json # Example JSON file
243
+ ```
244
+
245
+ ---
246
+
247
+ ## Testing
248
+
249
+ ```bash
250
+ # Run all tests
251
+ uv run pytest
252
+
253
+ # Run with verbose output
254
+ uv run pytest -v
255
+
256
+ # Run a specific test file
257
+ uv run pytest tests/test_tools/test_aggregate.py
258
+
259
+ # Run tests matching a name pattern
260
+ uv run pytest -k "test_filter"
261
+ ```
262
+
263
+ ---
264
+
265
+ ## Configuration
266
+
267
+ ### Environment variables
268
+
269
+ | Variable | Required | Default | Description |
270
+ |----------|----------|---------|-------------|
271
+ | `OPENROUTER_API_KEY` | Yes (web only) | — | Your OpenRouter API key |
272
+ | `OPENROUTER_MODEL` | No | `openai/gpt-4o-mini` | Any model from [openrouter.ai/models](https://openrouter.ai/models) |
273
+
274
+ ### MCP server config
275
+
276
+ The MCP server requires no configuration. It's registered via `.vscode/mcp.json` and uses stdio transport.
277
+
278
+ ---
279
+
280
+ ## Troubleshooting
281
+
282
+ | Problem | Solution |
283
+ |---------|----------|
284
+ | MCP server not appearing in Copilot | Make sure `.vscode/mcp.json` exists and the workspace is open. Restart VS Code. |
285
+ | "No document loaded" errors | Call `load_json` first before querying. |
286
+ | Truncated output | Large results are capped at ~10KB. Use specific paths or filters to narrow results. |
287
+ | `OPENROUTER_API_KEY not set` | Create a `.env` file from `.env.example` and add your key. |
288
+ | 429 Too Many Requests | You're rate-limited by the model provider. Wait a moment or switch to a different model. |
289
+ | Import errors in web server | Run `uv pip install -r web/requirements.txt` to install web dependencies. |