@dataville/dataville-mcp 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 Dataville
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,47 @@
1
+ # dataville-mcp
2
+
3
+ MCP server exposing Dataville's data source API as tools for MCP clients (Claude Desktop, Claude Code, etc.).
4
+
5
+ Requires a Dataville API key — get one from the [Dataville dashboard](https://app.dataville.com/api-keys).
6
+
7
+ ## Tools
8
+
9
+ - `list_dataville_sources` — lists the data sources available via `search_dataville`.
10
+ - `search_dataville` — query a data source: `{ source, keywords, params? }`.
11
+
12
+ ## Setup
13
+
14
+ Add this to your MCP client config (Claude Code / Claude Desktop), with `DATAVILLE_API_KEY` set to your own key:
15
+
16
+ ```json
17
+ {
18
+ "mcpServers": {
19
+ "dataville": {
20
+ "command": "npx",
21
+ "args": ["-y", "@dataville/dataville-mcp"],
22
+ "env": {
23
+ "DATAVILLE_API_KEY": "dataville_your_key_here"
24
+ }
25
+ }
26
+ }
27
+ }
28
+ ```
29
+
30
+ No install step needed — `npx` fetches and runs the package on demand.
31
+
32
+ `DATAVILLE_API_BASE_URL` is optional and defaults to `https://api.dataville.com`; set it to `http://localhost:5000` to point at a local backend during development.
33
+
34
+ ### Running from source
35
+
36
+ ```bash
37
+ git clone https://github.com/datavilleorg/dataville-mcp.git
38
+ cd dataville-mcp
39
+ npm install
40
+ npm run build
41
+ ```
42
+
43
+ ## Development
44
+
45
+ ```bash
46
+ npm run dev # tsx watch
47
+ ```
package/dist/client.js ADDED
@@ -0,0 +1,36 @@
1
+ const DEFAULT_BASE_URL = "https://api.dataville.com";
2
+ export class DatavilleApiError extends Error {
3
+ status;
4
+ constructor(status, message) {
5
+ super(message);
6
+ this.status = status;
7
+ this.name = "DatavilleApiError";
8
+ }
9
+ }
10
+ function getConfig() {
11
+ const apiKey = process.env.DATAVILLE_API_KEY;
12
+ if (!apiKey) {
13
+ throw new Error("DATAVILLE_API_KEY is not set. Generate an API key from the Dataville dashboard and set it in your MCP client config.");
14
+ }
15
+ const baseUrl = process.env.DATAVILLE_API_BASE_URL || DEFAULT_BASE_URL;
16
+ return { apiKey, baseUrl };
17
+ }
18
+ export async function searchDataSource(source, keywords, params) {
19
+ const { apiKey, baseUrl } = getConfig();
20
+ const url = new URL(`/${encodeURIComponent(source)}/${encodeURIComponent(keywords)}`, baseUrl);
21
+ if (params) {
22
+ for (const [key, value] of Object.entries(params)) {
23
+ url.searchParams.set(key, String(value));
24
+ }
25
+ }
26
+ const response = await fetch(url, {
27
+ headers: { Authorization: `Bearer ${apiKey}` },
28
+ });
29
+ const body = await response.json().catch(() => undefined);
30
+ if (!response.ok) {
31
+ const message = (body && typeof body === "object" && "error" in body && String(body.error)) ||
32
+ `Dataville API request failed with status ${response.status}`;
33
+ throw new DatavilleApiError(response.status, message);
34
+ }
35
+ return body;
36
+ }
package/dist/index.js ADDED
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env node
2
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
+ import { z } from "zod";
5
+ import { searchDataSource, DatavilleApiError } from "./client.js";
6
+ import { DATAVILLE_SOURCES } from "./sources.js";
7
+ const server = new McpServer({
8
+ name: "dataville-mcp-server",
9
+ version: "0.1.0",
10
+ });
11
+ server.registerTool("list_dataville_sources", {
12
+ title: "List Dataville data sources",
13
+ description: "List the data sources available through Dataville's search_dataville tool.",
14
+ inputSchema: {},
15
+ }, async () => ({
16
+ content: [{ type: "text", text: JSON.stringify(DATAVILLE_SOURCES, null, 2) }],
17
+ }));
18
+ server.registerTool("search_dataville", {
19
+ title: "Search a Dataville data source",
20
+ description: "Query one of Dataville's data sources (see list_dataville_sources for valid source names) with a keyword string and optional query params.",
21
+ inputSchema: {
22
+ source: z.string().describe("Data source name, e.g. 'wikipedia', 'arxiv', 'edgar'"),
23
+ keywords: z.string().describe("Search keywords or identifier for the query"),
24
+ params: z
25
+ .record(z.union([z.string(), z.number(), z.boolean()]))
26
+ .optional()
27
+ .describe("Optional additional query parameters"),
28
+ },
29
+ }, async ({ source, keywords, params }) => {
30
+ try {
31
+ const result = await searchDataSource(source, keywords, params);
32
+ return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
33
+ }
34
+ catch (error) {
35
+ const message = error instanceof DatavilleApiError ? error.message : String(error);
36
+ return { content: [{ type: "text", text: message }], isError: true };
37
+ }
38
+ });
39
+ async function main() {
40
+ const transport = new StdioServerTransport();
41
+ await server.connect(transport);
42
+ }
43
+ main().catch((error) => {
44
+ console.error("Fatal error starting Dataville MCP server:", error);
45
+ process.exit(1);
46
+ });
@@ -0,0 +1,14 @@
1
+ // Hand-maintained list of data sources supported by the Dataville API.
2
+ // Update when Dataville adds or removes a supported source.
3
+ export const DATAVILLE_SOURCES = [
4
+ { name: "wikipedia", description: "Wikipedia articles" },
5
+ { name: "arxiv", description: "arXiv preprints" },
6
+ { name: "gutenberg", description: "Project Gutenberg public-domain books" },
7
+ { name: "census", description: "US Census Bureau data" },
8
+ { name: "fooddata", description: "USDA FoodData Central" },
9
+ { name: "pwc", description: "Papers with Code — ML papers, code, and benchmarks" },
10
+ { name: "edgar", description: "SEC EDGAR filings" },
11
+ { name: "openalex", description: "OpenAlex scholarly works" },
12
+ { name: "pypi", description: "PyPI package metadata" },
13
+ { name: "stackexchange", description: "Stack Exchange Q&A" },
14
+ ];
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@dataville/dataville-mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server exposing Dataville's data source API as tools for MCP clients",
5
+ "private": false,
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/datavilleorg/dataville-mcp.git"
10
+ },
11
+ "type": "module",
12
+ "bin": {
13
+ "dataville-mcp": "dist/index.js"
14
+ },
15
+ "files": ["dist", "README.md", "LICENSE"],
16
+ "scripts": {
17
+ "build": "tsc",
18
+ "prepublishOnly": "npm run build",
19
+ "dev": "tsx watch src/index.ts",
20
+ "start": "node dist/index.js"
21
+ },
22
+ "dependencies": {
23
+ "@modelcontextprotocol/sdk": "^1.12.0",
24
+ "zod": "^3.24.1"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "^20.14.0",
28
+ "tsx": "^4.19.0",
29
+ "typescript": "^5.5.0"
30
+ }
31
+ }