@aborruso/ckan-mcp-server 0.4.16 → 0.4.18

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 (87) hide show
  1. package/LOG.md +78 -0
  2. package/README.md +104 -34
  3. package/dist/index.js +161 -45
  4. package/dist/worker.js +42 -42
  5. package/package.json +12 -1
  6. package/.devin/wiki.json +0 -273
  7. package/CLAUDE.md +0 -398
  8. package/PRD.md +0 -999
  9. package/REFACTORING.md +0 -238
  10. package/examples/langgraph/01_basic_workflow.py +0 -277
  11. package/examples/langgraph/02_data_exploration.py +0 -366
  12. package/examples/langgraph/README.md +0 -719
  13. package/examples/langgraph/metadata_quality.py +0 -299
  14. package/examples/langgraph/requirements.txt +0 -12
  15. package/examples/langgraph/setup.sh +0 -32
  16. package/examples/langgraph/test_setup.py +0 -106
  17. package/openspec/AGENTS.md +0 -456
  18. package/openspec/changes/add-ckan-analyze-dataset-structure/proposal.md +0 -17
  19. package/openspec/changes/add-ckan-analyze-dataset-structure/specs/ckan-insights/spec.md +0 -7
  20. package/openspec/changes/add-ckan-analyze-dataset-structure/tasks.md +0 -6
  21. package/openspec/changes/add-ckan-analyze-dataset-updates/proposal.md +0 -17
  22. package/openspec/changes/add-ckan-analyze-dataset-updates/specs/ckan-insights/spec.md +0 -7
  23. package/openspec/changes/add-ckan-analyze-dataset-updates/tasks.md +0 -6
  24. package/openspec/changes/add-ckan-audit-tool/proposal.md +0 -17
  25. package/openspec/changes/add-ckan-audit-tool/specs/ckan-insights/spec.md +0 -7
  26. package/openspec/changes/add-ckan-audit-tool/tasks.md +0 -6
  27. package/openspec/changes/add-ckan-dataset-insights/proposal.md +0 -17
  28. package/openspec/changes/add-ckan-dataset-insights/specs/ckan-insights/spec.md +0 -7
  29. package/openspec/changes/add-ckan-dataset-insights/tasks.md +0 -6
  30. package/openspec/changes/add-ckan-host-allowlist-env/design.md +0 -38
  31. package/openspec/changes/add-ckan-host-allowlist-env/proposal.md +0 -16
  32. package/openspec/changes/add-ckan-host-allowlist-env/specs/ckan-request-allowlist/spec.md +0 -15
  33. package/openspec/changes/add-ckan-host-allowlist-env/specs/cloudflare-deployment/spec.md +0 -11
  34. package/openspec/changes/add-ckan-host-allowlist-env/tasks.md +0 -12
  35. package/openspec/changes/add-escape-text-query/proposal.md +0 -12
  36. package/openspec/changes/add-escape-text-query/specs/ckan-search/spec.md +0 -11
  37. package/openspec/changes/add-escape-text-query/tasks.md +0 -8
  38. package/openspec/changes/add-mqa-quality-tool/proposal.md +0 -21
  39. package/openspec/changes/add-mqa-quality-tool/specs/ckan-quality/spec.md +0 -71
  40. package/openspec/changes/add-mqa-quality-tool/tasks.md +0 -29
  41. package/openspec/changes/archive/2026-01-08-add-mcp-resources/design.md +0 -115
  42. package/openspec/changes/archive/2026-01-08-add-mcp-resources/proposal.md +0 -52
  43. package/openspec/changes/archive/2026-01-08-add-mcp-resources/specs/mcp-resources/spec.md +0 -92
  44. package/openspec/changes/archive/2026-01-08-add-mcp-resources/tasks.md +0 -56
  45. package/openspec/changes/archive/2026-01-08-expand-test-coverage-specs/design.md +0 -355
  46. package/openspec/changes/archive/2026-01-08-expand-test-coverage-specs/proposal.md +0 -161
  47. package/openspec/changes/archive/2026-01-08-expand-test-coverage-specs/tasks.md +0 -162
  48. package/openspec/changes/archive/2026-01-08-translate-project-to-english/proposal.md +0 -115
  49. package/openspec/changes/archive/2026-01-08-translate-project-to-english/specs/documentation-language/spec.md +0 -32
  50. package/openspec/changes/archive/2026-01-08-translate-project-to-english/tasks.md +0 -115
  51. package/openspec/changes/archive/2026-01-10-add-ckan-find-relevant-datasets/proposal.md +0 -17
  52. package/openspec/changes/archive/2026-01-10-add-ckan-find-relevant-datasets/specs/ckan-insights/spec.md +0 -7
  53. package/openspec/changes/archive/2026-01-10-add-ckan-find-relevant-datasets/tasks.md +0 -6
  54. package/openspec/changes/archive/2026-01-10-add-cloudflare-workers/design.md +0 -734
  55. package/openspec/changes/archive/2026-01-10-add-cloudflare-workers/proposal.md +0 -183
  56. package/openspec/changes/archive/2026-01-10-add-cloudflare-workers/specs/cloudflare-deployment/spec.md +0 -389
  57. package/openspec/changes/archive/2026-01-10-add-cloudflare-workers/tasks.md +0 -519
  58. package/openspec/changes/archive/2026-01-15-add-mcp-prompts/proposal.md +0 -13
  59. package/openspec/changes/archive/2026-01-15-add-mcp-prompts/specs/mcp-prompts/spec.md +0 -22
  60. package/openspec/changes/archive/2026-01-15-add-mcp-prompts/tasks.md +0 -10
  61. package/openspec/changes/archive/2026-01-15-add-mcp-resource-filters/proposal.md +0 -13
  62. package/openspec/changes/archive/2026-01-15-add-mcp-resource-filters/specs/mcp-resources/spec.md +0 -38
  63. package/openspec/changes/archive/2026-01-15-add-mcp-resource-filters/tasks.md +0 -10
  64. package/openspec/changes/archive/2026-01-19-update-repo-owner-ondata/proposal.md +0 -13
  65. package/openspec/changes/archive/2026-01-19-update-repo-owner-ondata/specs/repository-metadata/spec.md +0 -14
  66. package/openspec/changes/archive/2026-01-19-update-repo-owner-ondata/tasks.md +0 -12
  67. package/openspec/changes/archive/2026-01-19-update-search-parser-config/proposal.md +0 -13
  68. package/openspec/changes/archive/2026-01-19-update-search-parser-config/specs/ckan-insights/spec.md +0 -11
  69. package/openspec/changes/archive/2026-01-19-update-search-parser-config/specs/ckan-search/spec.md +0 -11
  70. package/openspec/changes/archive/2026-01-19-update-search-parser-config/tasks.md +0 -6
  71. package/openspec/changes/archive/add-automated-tests/design.md +0 -324
  72. package/openspec/changes/archive/add-automated-tests/proposal.md +0 -167
  73. package/openspec/changes/archive/add-automated-tests/specs/automated-testing/spec.md +0 -143
  74. package/openspec/changes/archive/add-automated-tests/tasks.md +0 -132
  75. package/openspec/project.md +0 -115
  76. package/openspec/specs/ckan-insights/spec.md +0 -23
  77. package/openspec/specs/ckan-search/spec.md +0 -16
  78. package/openspec/specs/cloudflare-deployment/spec.md +0 -344
  79. package/openspec/specs/documentation-language/spec.md +0 -32
  80. package/openspec/specs/mcp-prompts/spec.md +0 -26
  81. package/openspec/specs/mcp-resources/spec.md +0 -120
  82. package/openspec/specs/repository-metadata/spec.md +0 -19
  83. package/private/commenti-privati.yaml +0 -14
  84. package/testo.md +0 -12
  85. package/web-gui/PRD.md +0 -158
  86. package/web-gui/public/index.html +0 -883
  87. package/wrangler.toml +0 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aborruso/ckan-mcp-server",
3
- "version": "0.4.16",
3
+ "version": "0.4.18",
4
4
  "description": "MCP server for interacting with CKAN open data portals",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -38,6 +38,8 @@
38
38
  "devDependencies": {
39
39
  "@types/express": "^4.17.21",
40
40
  "@types/node": "^20.12.12",
41
+ "@types/react": "^19.2.9",
42
+ "@types/react-dom": "^19.2.3",
41
43
  "@vitest/coverage-v8": "^4.0.16",
42
44
  "esbuild": "^0.27.2",
43
45
  "typescript": "^5.4.5",
@@ -47,6 +49,15 @@
47
49
  "publishConfig": {
48
50
  "access": "public"
49
51
  },
52
+ "files": [
53
+ "dist/",
54
+ "README.md",
55
+ "LICENSE.txt",
56
+ "NOTICE.md",
57
+ "LOG.md",
58
+ "EXAMPLES.md",
59
+ "AGENTS.md"
60
+ ],
50
61
  "engines": {
51
62
  "node": ">=18.0.0"
52
63
  }
package/.devin/wiki.json DELETED
@@ -1,273 +0,0 @@
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/CLAUDE.md DELETED
@@ -1,398 +0,0 @@
1
- <!-- OPENSPEC:START -->
2
- # OpenSpec Instructions
3
-
4
- These instructions are for AI assistants working in this project.
5
-
6
- Always open `@/openspec/AGENTS.md` when the request:
7
- - Mentions planning or proposals (words like proposal, spec, change, plan)
8
- - Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work
9
- - Sounds ambiguous and you need the authoritative spec before coding
10
-
11
- Use `@/openspec/AGENTS.md` to learn:
12
- - How to create and apply change proposals
13
- - Spec format and conventions
14
- - Project structure and guidelines
15
-
16
- Keep this managed block so 'openspec update' can refresh the instructions.
17
-
18
- <!-- OPENSPEC:END -->
19
-
20
- # CLAUDE.md
21
-
22
- This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
23
-
24
- **Important**: This project uses **English** as its primary language. All documentation, code comments, and commit messages should be in English.
25
-
26
- ## Project Overview
27
-
28
- CKAN MCP Server - MCP (Model Context Protocol) server for interacting with CKAN-based open data portals (dati.gov.it, data.gov, demo.ckan.org, etc.).
29
-
30
- The server exposes MCP tools for:
31
- - Advanced dataset search with Solr syntax
32
- - DataStore queries for tabular data analysis
33
- - Organization and group exploration
34
- - Complete metadata access
35
-
36
- ## Build and Development
37
-
38
- ### Main Commands
39
-
40
- ```bash
41
- # Build project (uses esbuild - fast and lightweight)
42
- npm run build
43
-
44
- # Run test suite (191 tests - unit + integration)
45
- npm test
46
-
47
- # Watch mode for tests during development
48
- npm run test:watch
49
-
50
- # Test coverage report
51
- npm run test:coverage
52
-
53
- # Start server in stdio mode (default for local integration)
54
- npm start
55
-
56
- # Start server in HTTP mode (for remote access)
57
- TRANSPORT=http PORT=3000 npm start
58
-
59
- # Watch mode for development
60
- npm run watch
61
-
62
- # Build + run
63
- npm run dev
64
-
65
- # Cloudflare Workers deployment (v0.4.0+)
66
- npm run build:worker # Build for Workers
67
- npm run dev:worker # Test locally with Wrangler
68
- npm run deploy # Deploy to Cloudflare Workers
69
- ```
70
-
71
- ### Build System
72
-
73
- The project uses **esbuild** for compilation and **vitest** for testing:
74
-
75
- - **Build**: Ultra-fast builds (milliseconds instead of minutes)
76
- - **Tests**: 191 tests (unit + integration) with 100% success rate
77
- - **Coverage**: ~39% overall (utils: 98%, tools: 15-20%) - available via vitest with v8 coverage engine
78
-
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
-
81
- The esbuild build bundles all internal modules but keeps external dependencies (`@modelcontextprotocol/sdk`, `axios`, `express`, `zod`) as external, so they must be present in `node_modules`.
82
-
83
- ### Testing
84
-
85
- The project has a comprehensive test suite using **Vitest**:
86
-
87
- ```
88
- tests/
89
- ├── unit/
90
- │ ├── formatting.test.ts # Utility functions (19 tests)
91
- │ ├── http.test.ts # HTTP client (11 tests)
92
- │ └── uri.test.ts # URI parsing (11 tests)
93
- ├── integration/
94
- │ ├── package.test.ts # Package tools (31 tests)
95
- │ ├── organization.test.ts # Organization tools (6 tests)
96
- │ ├── datastore.test.ts # DataStore tools (19 tests)
97
- │ ├── resources.test.ts # MCP Resources (11 tests)
98
- │ └── status.test.ts # Status tools (2 tests)
99
- └── fixtures/
100
- ├── responses/ # Success response mocks
101
- └── errors/ # Error scenario mocks
102
- ```
103
-
104
- **Test Coverage**: 191 tests total (117 unit + 74 integration)
105
-
106
- When making changes:
107
- 1. Run tests before committing: `npm test`
108
- 2. Ensure all tests pass
109
- 3. Add tests for new features or bug fixes
110
- 4. Follow existing test patterns in `tests/` directory
111
-
112
- ## Architecture
113
-
114
- ### Code Structure
115
-
116
- The server is implemented with a modular structure to improve maintainability and testability:
117
-
118
- ```
119
- src/
120
- ├── index.ts # Entry point Node.js (42 lines)
121
- ├── worker.ts # Entry point Cloudflare Workers (95 lines) [v0.4.0+]
122
- ├── server.ts # MCP server setup (12 lines)
123
- ├── types.ts # Types & schemas (16 lines)
124
- ├── utils/
125
- │ ├── http.ts # CKAN API client (51 lines)
126
- │ └── formatting.ts # Output formatting (37 lines)
127
- ├── tools/
128
- │ ├── package.ts # Package tools (350 lines)
129
- │ ├── organization.ts # Organization tools (341 lines)
130
- │ ├── datastore.ts # DataStore tools (146 lines)
131
- │ └── status.ts # Status tools (66 lines)
132
- ├── resources/ # MCP Resource Templates
133
- │ ├── index.ts # Resource registration (19 lines)
134
- │ ├── uri.ts # URI parsing utilities (50 lines)
135
- │ ├── dataset.ts # Dataset resource (56 lines)
136
- │ ├── resource.ts # Resource resource (56 lines)
137
- │ └── organization.ts # Organization resource (58 lines)
138
- └── transport/
139
- ├── stdio.ts # Stdio transport (12 lines)
140
- └── http.ts # HTTP transport (27 lines)
141
- ```
142
-
143
- **Total**: ~1445 lines (including Workers deployment)
144
-
145
- **Note**: `worker.ts` (v0.4.0+) is an alternative entry point for Cloudflare Workers deployment. Tool handlers (`tools/*`) are shared between Node.js and Workers runtimes.
146
-
147
- The server (`src/index.ts`):
148
-
149
- 1. **Entry Point** (`index.ts`)
150
- - Imports and registers all tools
151
- - Chooses transport (stdio/http) from environment variable
152
- - Handles startup and error handling
153
-
154
- 2. **Registered Tools** (in separate modules)
155
- - `tools/package.ts`: `ckan_package_search`, `ckan_package_show`
156
- - `tools/organization.ts`: `ckan_organization_list`, `ckan_organization_show`, `ckan_organization_search`
157
- - `tools/datastore.ts`: `ckan_datastore_search`
158
- - `tools/status.ts`: `ckan_status_show`
159
-
160
- 3. **MCP Resource Templates** (`resources/`)
161
- - `ckan://{server}/dataset/{id}` - Dataset metadata
162
- - `ckan://{server}/resource/{id}` - Resource metadata
163
- - `ckan://{server}/organization/{name}` - Organization metadata
164
-
165
- 4. **Utility Functions** (`utils/`)
166
- - `http.ts`: `makeCkanRequest<T>()` - HTTP client for CKAN API v3
167
- - `formatting.ts`: `truncateText()`, `formatDate()`, `formatBytes()`
168
-
169
- 5. **Type Definitions** (`types.ts`)
170
- - `ResponseFormat` enum (MARKDOWN, JSON)
171
- - `ResponseFormatSchema` Zod validator
172
- - `CHARACTER_LIMIT` constant
173
-
174
- 5. **Transport Layer** (`transport/`)
175
- - `stdio.ts`: Standard input/output (Claude Desktop)
176
- - `http.ts`: HTTP server (remote access)
177
-
178
- 6. **Validation Schema**
179
- - Uses Zod to validate all tool inputs
180
- - Each tool has a strict schema that rejects extra parameters
181
-
182
- 7. **Output Formatting**
183
- - All tools support two formats: `markdown` (default) and `json`
184
- - Markdown format optimized for human readability
185
- - JSON format for programmatic processing
186
-
187
- ### Transport Modes
188
-
189
- The server supports three transport modes:
190
-
191
- - **stdio** (default): for integration with Claude Desktop and other local MCP clients
192
- - **http**: exposes POST `/mcp` endpoint on configurable port (default 3000)
193
- - **Cloudflare Workers** (v0.4.0+): global edge deployment via `src/worker.ts`
194
-
195
- ### Cloudflare Workers Deployment
196
-
197
- **Added in v0.4.0**. The server can be deployed to Cloudflare Workers for global HTTP access.
198
-
199
- **Key files**:
200
- - `src/worker.ts` - Workers entry point using Web Standards transport
201
- - `wrangler.toml` - Cloudflare configuration
202
-
203
- **Deployment workflow**:
204
- 1. `npm run dev:worker` - Test locally (http://localhost:8787)
205
- 2. `npm run deploy` - Deploy to Cloudflare
206
- 3. Access at: `https://ckan-mcp-server.<account>.workers.dev`
207
-
208
- **Architecture**:
209
- - Uses `WebStandardStreamableHTTPServerTransport` from MCP SDK
210
- - Compatible with Workers runtime (no Node.js APIs)
211
- - Stateless mode (no session management)
212
- - All 7 tools and 3 resource templates work identically to Node.js version
213
-
214
- See `docs/DEPLOYMENT.md` for complete deployment guide.
215
-
216
- ### CKAN API Integration
217
-
218
- The server uses CKAN API v3 available on any CKAN portal. All requests:
219
-
220
- - Use `axios` with 30 second timeout
221
- - Send User-Agent `CKAN-MCP-Server/1.0`
222
- - Handle HTTP errors, timeouts, and server not found
223
- - Normalize server URL (removing trailing slash)
224
- - Validate that `response.success === true`
225
-
226
- ### Solr Queries
227
-
228
- CKAN uses Apache Solr for search. The `ckan_package_search` tool supports:
229
-
230
- - **q** (query): complete Solr syntax (field:value, AND/OR/NOT, wildcard, range)
231
- - **fq** (filter query): additional filters without affecting score
232
- - **facet_field**: aggregations for statistical analysis
233
- - **sort**: result ordering
234
- - **start/rows**: pagination
235
-
236
- Common query examples are documented in `EXAMPLES.md`.
237
-
238
- ## TypeScript Configuration
239
-
240
- The project uses ES2022 as target and module system.
241
-
242
- **Note**: `tsconfig.json` is present mainly for editor support (IDE, LSP). The actual compilation uses esbuild which ignores most TypeScript options to maximize speed.
243
-
244
- TypeScript configuration (for IDE):
245
- - Output in `dist/` directory
246
- - Strict mode enabled
247
- - Strict type checking with noUnusedLocals, noUnusedParameters, noImplicitReturns
248
- - Skip lib check to reduce overhead
249
- - Declaration and source map disabled
250
-
251
- ## Dependencies
252
-
253
- **Runtime**:
254
- - `@modelcontextprotocol/sdk` - Official MCP SDK
255
- - `axios` - HTTP client for CKAN API
256
- - `zod` - Schema validation
257
- - `express` - HTTP server (only for http mode)
258
-
259
- **Dev**:
260
- - `esbuild` - Build tool (bundler and compiler)
261
- - `typescript` - Only for type checking and editor support
262
- - `@types/node`, `@types/express` - Type definitions
263
-
264
- ## Supported CKAN Portals
265
-
266
- The server can connect to any CKAN instance. Some main portals:
267
-
268
- - 🇮🇹 https://dati.gov.it (Italy)
269
- - 🇺🇸 https://catalog.data.gov (United States)
270
- - 🇨🇦 https://open.canada.ca/data (Canada)
271
- - 🇬🇧 https://data.gov.uk (United Kingdom)
272
- - 🇪🇺 https://data.europa.eu (European Union)
273
- - 🌍 https://demo.ckan.org (Official CKAN Demo)
274
-
275
- Each portal may have different configurations for:
276
- - DataStore availability
277
- - Custom dataset fields
278
- - Available organizations and tags
279
- - Supported resource formats
280
-
281
-
282
- The project uses **Vitest** for automated testing:
283
-
284
- ```bash
285
- # Run all tests
286
- npm test
287
-
288
- # Run tests in watch mode
289
- npm run test:watch
290
-
291
- # Run tests with coverage report
292
- npm run test:coverage
293
- ```
294
-
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)
299
- - Integration tests for MCP tools with mocked CKAN API responses
300
- - Mock fixtures for CKAN API success and error scenarios
301
-
302
- Coverage is strong for utility modules but needs improvement for tool handlers.
303
- See `tests/README.md` for detailed testing guidelines and fixture structure.
304
-
305
- ### Manual Testing
306
-
307
- For manual testing:
308
-
309
- ```bash
310
- # Build project
311
- npm run build
312
-
313
- # Test stdio mode
314
- npm start
315
- # (Server will wait for MCP commands on stdin)
316
-
317
- # Test HTTP mode in a terminal
318
- TRANSPORT=http PORT=3000 npm start
319
-
320
- # In another terminal, test with curl
321
- curl -X POST http://localhost:3000/mcp \
322
- -H "Content-Type: application/json" \
323
- -d {"jsonrpc":"2.0","method":"tools/list","id":1}
324
- ```
325
-
326
- To test with Claude Desktop, add MCP configuration to config file.
327
- To test with Claude Desktop, add the MCP configuration to the config file.
328
-
329
- ## Development Notes
330
-
331
- ### Version History
332
-
333
- **v0.4.0 (2026-01-10)**: Cloudflare Workers deployment
334
- - Added `src/worker.ts` for Workers runtime
335
- - Global edge deployment support
336
- - Web Standards transport integration
337
- - See `docs/DEPLOYMENT.md` for deployment guide
338
-
339
- **v0.3.0 (2026-01-08)**: MCP Resource Templates
340
- - Added `ckan://` URI scheme support
341
- - Direct data access for datasets, resources, organizations
342
-
343
- **v0.2.0 (2026-01-08)**: Comprehensive test suite
344
- - 191 tests (unit + integration)
345
- - ~39% code coverage (utils well-tested, tools improving)
346
-
347
- **v0.1.0 (2026-01-08)**: Modular refactoring
348
- - Restructured from monolithic file to 11 modules
349
- - Improved maintainability and testability
350
-
351
- ### Known Limitations
352
-
353
- - **Output limit**: 50,000 characters hardcoded in `types.ts` (could be configurable)
354
- - **Date formatting**: Uses fixed ISO `YYYY-MM-DD` in `utils/formatting.ts` (could be configurable)
355
- - **Read-only**: All tools are read-only (no data modification on CKAN)
356
- - **No caching**: Every request makes fresh HTTP call to CKAN APIs
357
- - **No authentication**: Uses only public CKAN endpoints
358
- - **No WebSocket**: MCP over HTTP uses JSON responses (not SSE streaming in Workers)
359
-
360
- ### Adding New Tools
361
-
362
- 1. Create new file in `src/tools/`
363
- 2. Export `registerXxxTools(server: McpServer)` function
364
- 3. Add to `registerAll()` in `src/server.ts`
365
- 4. Add tests in `tests/integration/`
366
- 5. Build and test: `npm run build && npm test`
367
-
368
- ### Release Workflow
369
-
370
- When releasing a new version:
371
-
372
- 1. **Update version**: Edit `package.json` version field
373
- 2. **Update LOG.md**: Add entry with date and changes
374
- 3. **Commit changes**: `git add . && git commit -m "..."`
375
- 4. **Push to GitHub**: `git push origin main`
376
- 5. **Create tag**: `git tag -a v0.x.0 -m "..." && git push origin v0.x.0`
377
- 6. **Publish to npm** (optional): `npm publish`
378
- 7. **Deploy to Cloudflare** (if code changed): `npm run deploy`
379
-
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
- ```