@aborruso/ckan-mcp-server 0.4.8 → 0.4.10

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.
@@ -0,0 +1,273 @@
1
+ {
2
+ "repo_notes": [
3
+ {
4
+ "content": ""
5
+ }
6
+ ],
7
+ "pages": [
8
+ {
9
+ "title": "Overview",
10
+ "purpose": "Introduce the CKAN MCP Server system, explaining its purpose as a Model Context Protocol server that enables AI agents to interact with 500+ CKAN open data portals worldwide through natural language and structured queries",
11
+ "page_notes": [
12
+ {
13
+ "content": ""
14
+ }
15
+ ]
16
+ },
17
+ {
18
+ "title": "Key Features",
19
+ "purpose": "Highlight the main capabilities: 15+ CKAN tools, dual runtime support, MCP Resource Templates, and global edge deployment",
20
+ "parent": "Overview",
21
+ "page_notes": [
22
+ {
23
+ "content": ""
24
+ }
25
+ ]
26
+ },
27
+ {
28
+ "title": "Architecture Overview",
29
+ "purpose": "Provide a high-level architectural diagram showing the two-tier system: MCP Server Core and CKAN Portals, plus the dual deployment model",
30
+ "parent": "Overview",
31
+ "page_notes": [
32
+ {
33
+ "content": ""
34
+ }
35
+ ]
36
+ },
37
+ {
38
+ "title": "Getting Started",
39
+ "purpose": "Guide users through the fastest path to using the system based on their needs and technical expertise",
40
+ "page_notes": [
41
+ {
42
+ "content": ""
43
+ }
44
+ ]
45
+ },
46
+ {
47
+ "title": "Claude Desktop Setup",
48
+ "purpose": "Configure Claude Desktop to use the MCP server via stdio (local) or HTTP (remote/Workers) transport modes",
49
+ "parent": "Getting Started",
50
+ "page_notes": [
51
+ {
52
+ "content": ""
53
+ }
54
+ ]
55
+ },
56
+ {
57
+ "title": "Installation Options",
58
+ "purpose": "Compare the three deployment options: npm global install, Cloudflare Workers, and self-hosted HTTP server",
59
+ "parent": "Getting Started",
60
+ "page_notes": [
61
+ {
62
+ "content": ""
63
+ }
64
+ ]
65
+ },
66
+ {
67
+ "title": "Architecture",
68
+ "purpose": "Deep dive into the system architecture, component relationships, and design decisions",
69
+ "page_notes": [
70
+ {
71
+ "content": ""
72
+ }
73
+ ]
74
+ },
75
+ {
76
+ "title": "System Components",
77
+ "purpose": "Explain the modular architecture: entry points, transport layer, server core, tool handlers, resource templates, and utilities",
78
+ "parent": "Architecture",
79
+ "page_notes": [
80
+ {
81
+ "content": ""
82
+ }
83
+ ]
84
+ },
85
+ {
86
+ "title": "MCP Server Core",
87
+ "purpose": "Explain the MCP server implementation: tool registration system, request routing, Zod validation, and error handling",
88
+ "parent": "Architecture",
89
+ "page_notes": [
90
+ {
91
+ "content": ""
92
+ }
93
+ ]
94
+ },
95
+ {
96
+ "title": "Transport Layer",
97
+ "purpose": "Document the three transport modes: stdio (12 lines), HTTP (27 lines), and Cloudflare Workers WebStandardStreamable, explaining how the same tools run across different runtimes",
98
+ "parent": "Architecture",
99
+ "page_notes": [
100
+ {
101
+ "content": ""
102
+ }
103
+ ]
104
+ },
105
+ {
106
+ "title": "Tool Layer",
107
+ "purpose": "Describe the tool implementation pattern: Zod schemas, handler functions, makeCkanRequest abstraction, and output formatting (1,465+ lines of business logic)",
108
+ "parent": "Architecture",
109
+ "page_notes": [
110
+ {
111
+ "content": ""
112
+ }
113
+ ]
114
+ },
115
+ {
116
+ "title": "Dual Runtime Design",
117
+ "purpose": "Explain how the same codebase runs on Node.js and Cloudflare Workers V8 isolates, including build targets, bundle sizes, and runtime differences",
118
+ "parent": "Architecture",
119
+ "page_notes": [
120
+ {
121
+ "content": ""
122
+ }
123
+ ]
124
+ },
125
+ {
126
+ "title": "User Guides",
127
+ "purpose": "Practical guides for end users interacting with CKAN data through the system",
128
+ "page_notes": [
129
+ {
130
+ "content": ""
131
+ }
132
+ ]
133
+ },
134
+ {
135
+ "title": "Querying CKAN Data",
136
+ "purpose": "Guide to common CKAN queries: searching datasets, exploring organizations, querying DataStore, using facets, and understanding Solr syntax",
137
+ "parent": "User Guides",
138
+ "page_notes": [
139
+ {
140
+ "content": ""
141
+ }
142
+ ]
143
+ },
144
+ {
145
+ "title": "Advanced Search Techniques",
146
+ "purpose": "Document Solr query syntax: fuzzy search (~N), proximity search (\"phrase\"~N), boosting (^N), range queries, date math, wildcards, and boolean operators",
147
+ "parent": "User Guides",
148
+ "page_notes": [
149
+ {
150
+ "content": ""
151
+ }
152
+ ]
153
+ },
154
+ {
155
+ "title": "DataStore Queries",
156
+ "purpose": "Explain DataStore functionality: basic key-value filtering, SQL queries, field selection, sorting, pagination, and the 32,000 record limit",
157
+ "parent": "User Guides",
158
+ "page_notes": [
159
+ {
160
+ "content": ""
161
+ }
162
+ ]
163
+ },
164
+ {
165
+ "title": "Working with Organizations",
166
+ "purpose": "Guide to organization tools: listing with package counts, searching by pattern, retrieving details, and understanding organizational hierarchies",
167
+ "parent": "User Guides",
168
+ "page_notes": [
169
+ {
170
+ "content": ""
171
+ }
172
+ ]
173
+ },
174
+ {
175
+ "title": "Tool Reference",
176
+ "purpose": "Complete reference documentation for all 15+ MCP tools with parameters, return types, and usage examples",
177
+ "page_notes": [
178
+ {
179
+ "content": ""
180
+ }
181
+ ]
182
+ },
183
+ {
184
+ "title": "Dataset Tools",
185
+ "purpose": "Document ckan_package_search, ckan_find_relevant_datasets, ckan_package_show, ckan_package_list with detailed parameter descriptions and examples",
186
+ "parent": "Tool Reference",
187
+ "page_notes": [
188
+ {
189
+ "content": ""
190
+ }
191
+ ]
192
+ },
193
+ {
194
+ "title": "Organization Tools",
195
+ "purpose": "Document ckan_organization_list, ckan_organization_show, ckan_organization_search with sorting, pagination, and filtering options",
196
+ "parent": "Tool Reference",
197
+ "page_notes": [
198
+ {
199
+ "content": ""
200
+ }
201
+ ]
202
+ },
203
+ {
204
+ "title": "DataStore Tools",
205
+ "purpose": "Document ckan_datastore_search and ckan_datastore_search_sql with filtering syntax, SQL query examples, and limit constraints",
206
+ "parent": "Tool Reference",
207
+ "page_notes": [
208
+ {
209
+ "content": ""
210
+ }
211
+ ]
212
+ },
213
+ {
214
+ "title": "Metadata Tools",
215
+ "purpose": "Document ckan_tag_list, ckan_group_list, ckan_group_show, ckan_group_search, and ckan_status_show for portal exploration",
216
+ "parent": "Tool Reference",
217
+ "page_notes": [
218
+ {
219
+ "content": ""
220
+ }
221
+ ]
222
+ },
223
+ {
224
+ "title": "MCP Resource Templates",
225
+ "purpose": "Explain the ckan:// URI scheme for accessing datasets, resources, and organizations via MCP Resource Templates",
226
+ "parent": "Tool Reference",
227
+ "page_notes": [
228
+ {
229
+ "content": ""
230
+ }
231
+ ]
232
+ },
233
+ {
234
+ "title": "Developer Guide",
235
+ "purpose": "Guide for developers who want to modify, extend, or contribute to the codebase",
236
+ "page_notes": [
237
+ {
238
+ "content": ""
239
+ }
240
+ ]
241
+ },
242
+ {
243
+ "title": "Project Structure",
244
+ "purpose": "Document the codebase organization: src/ structure, tool modules (1,465+ lines), utilities (138+ lines), resources (50+ lines), and test organization (2,340 lines)",
245
+ "parent": "Developer Guide",
246
+ "page_notes": [
247
+ {
248
+ "content": ""
249
+ }
250
+ ]
251
+ },
252
+ {
253
+ "title": "Adding New Tools",
254
+ "purpose": "Step-by-step guide to implementing a new MCP tool: defining Zod schemas, creating handlers, using makeCkanRequest, formatting outputs, and registering with the server",
255
+ "parent": "Developer Guide",
256
+ "page_notes": [
257
+ {
258
+ "content": ""
259
+ }
260
+ ]
261
+ },
262
+ {
263
+ "title": "Utility Functions",
264
+ "purpose": "Document the utility layer: makeCkanRequest (51 lines, 98.59% coverage), formatting functions (37 lines, 98% coverage), query resolution, and URL generation",
265
+ "parent": "Developer Guide",
266
+ "page_notes": [
267
+ {
268
+ "content": ""
269
+ }
270
+ ]
271
+ }
272
+ ]
273
+ }
package/AGENTS.md CHANGED
@@ -4,15 +4,97 @@
4
4
  These instructions are for AI assistants working in this project.
5
5
 
6
6
  Always open `@/openspec/AGENTS.md` when the request:
7
+
7
8
  - Mentions planning or proposals (words like proposal, spec, change, plan)
8
9
  - Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work
9
10
  - Sounds ambiguous and you need the authoritative spec before coding
10
11
 
11
12
  Use `@/openspec/AGENTS.md` to learn:
13
+
12
14
  - How to create and apply change proposals
13
15
  - Spec format and conventions
14
16
  - Project structure and guidelines
15
17
 
16
18
  Keep this managed block so 'openspec update' can refresh the instructions.
17
19
 
18
- <!-- OPENSPEC:END -->
20
+ <!-- OPENSPEC:END -->
21
+
22
+ # Agent Guide
23
+
24
+ ## Scope
25
+
26
+ - Repo: `ckan-mcp-server`
27
+ - Stack: Node.js + TypeScript (ESM)
28
+ - Tests: Vitest
29
+ - Build: esbuild
30
+ - Cloudflare Workers: `wrangler`
31
+
32
+ ## Cursor and Copilot Rules
33
+
34
+ - No `.cursor/rules`, `.cursorrules`, or `.github/copilot-instructions.md` found
35
+
36
+ ## Commands
37
+
38
+ **Install**: `npm install`
39
+
40
+ **Build**: `npm run build` | `npm run build:tsc` | `npm run build:worker`
41
+
42
+ **Run**: `npm start` | `npm run dev` | `npm run watch` | `npm run dev:worker` | `npm run deploy`
43
+
44
+ **Test**: `npm test` | `npm run test:watch` | `npm run test:coverage`
45
+
46
+ **Single test**: `npm test -- tests/unit/http.test.ts` | `npm test -- -t "testName"`
47
+
48
+ ## TypeScript Style
49
+
50
+ Use strict typing, avoid `any` unless from CKAN payloads. Prefer explicit return types, `type` aliases, ESM imports with `.js` extensions. Keep `noUnusedLocals` and `noUnusedParameters` clean.
51
+
52
+ ## Import Conventions
53
+
54
+ Use `import type` for type-only imports. Group by kind: external, internal, types. Double quotes, relative paths.
55
+
56
+ ## Naming
57
+
58
+ `camelCase` vars/functions, `PascalCase` types/classes, `UPPER_SNAKE_CASE` constants. Tool names match MCP tool ids.
59
+
60
+ ## Error Handling
61
+
62
+ Wrap tool handlers in `try/catch`. Return `{ isError: true }` for MCP errors. Include context, map HTTP errors to readable messages, preserve cause when rethrowing.
63
+
64
+ ## Tool Responses
65
+
66
+ Use `ResponseFormat` for markdown vs JSON. `truncateText` for large payloads. Pretty-print JSON, include `structuredContent` for JSON mode.
67
+
68
+ ## Testing Guidelines
69
+
70
+ Vitest with `globals: true`. Place tests in `tests/unit` or `tests/integration`. AAA pattern, mock via fixtures in `tests/fixtures`, descriptive names.
71
+
72
+ ## Configuration
73
+
74
+ Node `>=18`. Worker build in `wrangler.toml`. Vitest coverage thresholds enforced.
75
+
76
+ ## Change Hygiene
77
+
78
+ Minimal focused diffs. No unrelated refactors. Update tests for behavior changes. Avoid editing `dist/`.
79
+
80
+ ## Project Layout
81
+
82
+ `src/index.ts` entry, `src/server.ts` wiring, `src/tools/` handlers, `src/utils/` helpers, `src/resources/` templates, `src/transport/` stdio/HTTP. `tests/unit/` utilities, `tests/integration/` behavior, `tests/fixtures/` mocks.
83
+
84
+ ## CSV Data Exploration
85
+
86
+ For exploring CSV resources from datasets, use duckdb CLI (already installed) with direct HTTP URL:
87
+
88
+ ```bash
89
+ duckdb -jsonlines -c "DESCRIBE SELECT * FROM read_csv('http://url/file.csv')"
90
+ duckdb -jsonlines -c "SUMMARIZE SELECT * FROM read_csv('http://url/file.csv')"
91
+ duckdb -jsonlines -c "SELECT * FROM read_csv('http://url/file.csv') USING SAMPLE 10"
92
+ ```
93
+
94
+ Use direct resource URLs (http/https), not GitHub view/blob URLs. The `-jsonlines` parameter outputs in JSONL format, easier for AI to parse.
95
+
96
+ For random sampling, use `USING SAMPLE N` syntax (where N is the number of rows):
97
+
98
+ ```bash
99
+ duckdb -jsonlines -c "SELECT * FROM read_csv('http://url/file.csv') USING SAMPLE 10"
100
+ ```
package/CLAUDE.md CHANGED
@@ -41,7 +41,7 @@ The server exposes MCP tools for:
41
41
  # Build project (uses esbuild - fast and lightweight)
42
42
  npm run build
43
43
 
44
- # Run test suite (113 tests - unit + integration)
44
+ # Run test suite (179 tests - unit + integration)
45
45
  npm test
46
46
 
47
47
  # Watch mode for tests during development
@@ -73,8 +73,8 @@ npm run deploy # Deploy to Cloudflare Workers
73
73
  The project uses **esbuild** for compilation and **vitest** for testing:
74
74
 
75
75
  - **Build**: Ultra-fast builds (milliseconds instead of minutes)
76
- - **Tests**: 101 tests (unit + integration) with 100% success rate
77
- - **Coverage**: Available via vitest with v8 coverage engine
76
+ - **Tests**: 179 tests (unit + integration) with 100% success rate
77
+ - **Coverage**: ~39% overall (utils: 98%, tools: 15-20%) - available via vitest with v8 coverage engine
78
78
 
79
79
  The `build:tsc` script is available as a fallback but can cause memory issues in some environments (particularly WSL). Always use `npm run build` which uses esbuild.
80
80
 
@@ -101,7 +101,7 @@ tests/
101
101
  └── errors/ # Error scenario mocks
102
102
  ```
103
103
 
104
- **Test Coverage**: 101 tests total (36 unit + 65 integration)
104
+ **Test Coverage**: 179 tests total (85 unit + 94 integration)
105
105
 
106
106
  When making changes:
107
107
  1. Run tests before committing: `npm test`
@@ -292,11 +292,14 @@ npm run test:watch
292
292
  npm run test:coverage
293
293
  ```
294
294
 
295
- Test coverage target is 80%. Current test suite includes:
296
- - Unit tests for utility functions (formatting, HTTP)
295
+ Current test coverage: ~39% overall (utility modules: 98%, tool handlers: 15-20%).
296
+
297
+ Test suite includes:
298
+ - Unit tests for utility functions (formatting, HTTP, URI parsing, URL generation, search)
297
299
  - Integration tests for MCP tools with mocked CKAN API responses
298
300
  - Mock fixtures for CKAN API success and error scenarios
299
301
 
302
+ Coverage is strong for utility modules but needs improvement for tool handlers.
300
303
  See `tests/README.md` for detailed testing guidelines and fixture structure.
301
304
 
302
305
  ### Manual Testing
@@ -338,8 +341,8 @@ To test with Claude Desktop, add the MCP configuration to the config file.
338
341
  - Direct data access for datasets, resources, organizations
339
342
 
340
343
  **v0.2.0 (2026-01-08)**: Comprehensive test suite
341
- - 113 tests (unit + integration)
342
- - 97%+ code coverage
344
+ - 179 tests (unit + integration)
345
+ - ~39% code coverage (utils well-tested, tools improving)
343
346
 
344
347
  **v0.1.0 (2026-01-08)**: Modular refactoring
345
348
  - Restructured from monolithic file to 11 modules
@@ -375,3 +378,21 @@ When releasing a new version:
375
378
  7. **Deploy to Cloudflare** (if code changed): `npm run deploy`
376
379
 
377
380
  See `docs/DEPLOYMENT.md` for detailed Cloudflare deployment instructions.
381
+
382
+ ## CSV Data Exploration
383
+
384
+ For exploring CSV resources from datasets, use duckdb CLI (already installed) with direct HTTP URL:
385
+
386
+ ```bash
387
+ duckdb -jsonlines -c "DESCRIBE SELECT * FROM read_csv('http://url/file.csv')"
388
+ duckdb -jsonlines -c "SUMMARIZE SELECT * FROM read_csv('http://url/file.csv')"
389
+ duckdb -jsonlines -c "SELECT * FROM read_csv('http://url/file.csv') USING SAMPLE 10"
390
+ ```
391
+
392
+ Use direct resource URLs (http/https), not GitHub view/blob URLs. The `-jsonlines` parameter outputs in JSONL format, easier for AI to parse.
393
+
394
+ For random sampling, use `USING SAMPLE N` syntax (where N is the number of rows):
395
+
396
+ ```bash
397
+ duckdb -jsonlines -c "SELECT * FROM read_csv('http://url/file.csv') USING SAMPLE 10"
398
+ ```
package/LOG.md CHANGED
@@ -1,5 +1,61 @@
1
1
  # LOG
2
2
 
3
+ ## 2026-01-15
4
+
5
+ ### Version 0.4.10 - Guided MCP prompts
6
+ - **Feature**: Added 5 guided MCP prompts (theme, organization, format, recent datasets, dataset analysis)
7
+ - **Docs**: README and new `docs/prompts.md` updated with usage examples
8
+ - **Tests**: Added prompt unit tests; total now 184 tests (all passing)
9
+ - **Files**: New `src/prompts/*`, updates in `src/server.ts`, `src/worker.ts`, README.md
10
+
11
+ ## 2026-01-11
12
+
13
+ ### Version 0.4.9 - Security, Testing & Documentation
14
+ - **Security**: Updated @modelcontextprotocol/sdk from 1.25.1 to 1.25.2 (fixes HIGH severity ReDoS vulnerability)
15
+ - **Testing**: Added 49 new unit tests for package.ts scoring functions
16
+ - **Coverage**: Improved from 37.33% to 38.63% (package.ts: 12.5% to 15%)
17
+ - **Total tests**: 179 tests (all passing, +49 from 130)
18
+ - **Documentation**: Corrected test coverage claims (was "113 tests, 97%+" now accurate "179 tests, ~39%")
19
+ - **Deployment**: Added npm audit check to DEPLOYMENT.md
20
+ - **Files modified**: package.json, src/server.ts, src/worker.ts, README.md, CLAUDE.md, docs/DEPLOYMENT.md
21
+ - **New file**: tests/unit/package-scoring.test.ts
22
+ - **No breaking changes**: All existing functionality preserved
23
+
24
+ ### Test improvements - package scoring functions
25
+ - **Added**: 49 new unit tests for package.ts scoring functions
26
+ - **Coverage improvement**: package.ts from 12.5% to 15%
27
+ - **Overall coverage**: 37.33% to 38.63%
28
+ - **Total tests**: 130 to 179 tests (all passing)
29
+ - **New test file**: tests/unit/package-scoring.test.ts
30
+ - **Functions tested**:
31
+ - extractQueryTerms (10 tests)
32
+ - escapeRegExp (6 tests)
33
+ - textMatchesTerms (10 tests)
34
+ - scoreTextField (6 tests)
35
+ - scoreDatasetRelevance (17 tests with edge cases)
36
+ - **Exports**: Made internal functions testable (extractQueryTerms, escapeRegExp, textMatchesTerms, scoreTextField)
37
+ - **Impact**: Better coverage of dataset relevance scoring logic
38
+
39
+ ### Documentation corrections - test coverage accuracy
40
+ - **Fix**: Corrected test coverage claims in README.md and CLAUDE.md
41
+ - **Previous claim**: "113 tests, 97%+ coverage"
42
+ - **Actual values**: 130 tests passing, ~37% overall coverage
43
+ - Utility modules: 98% coverage (excellent)
44
+ - Tool handlers: 12-20% coverage (needs improvement)
45
+ - **Impact**: Documentation now accurately reflects project state
46
+ - **Files modified**: README.md, CLAUDE.md
47
+
48
+ ### Documentation enhancement - deployment security
49
+ - **Added**: npm audit check to DEPLOYMENT.md (Step 4.5)
50
+ - **Added**: Security audit to pre-release checklist
51
+ - **Recommendation**: Always run `npm audit` before production deployment
52
+
53
+ ### Security fix - MCP SDK update
54
+ - **Fix**: Update @modelcontextprotocol/sdk from 1.25.1 to 1.25.2
55
+ - **Reason**: Resolves HIGH severity ReDoS vulnerability (GHSA-8r9q-7v3j-jr4g)
56
+ - **Tests**: All 130 tests passing
57
+ - **Audit**: 0 vulnerabilities
58
+
3
59
  ## 2026-01-10
4
60
 
5
61
  ### Version 0.4.8 - Organization list fallback