@dataville/dataville-mcp 0.1.1 → 0.1.2

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/dist/client.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const DEFAULT_BASE_URL = "https://api.dataville.com";
2
2
  // Keep in sync with package.json version (enforced by a test).
3
- export const VERSION = "0.1.1";
3
+ export const VERSION = "0.1.2";
4
4
  const USER_AGENT = `dataville-mcp/${VERSION}`;
5
5
  export class DatavilleApiError extends Error {
6
6
  status;
@@ -10,6 +10,21 @@ export class DatavilleApiError extends Error {
10
10
  this.name = "DatavilleApiError";
11
11
  }
12
12
  }
13
+ /**
14
+ * Raised when the API accepted the request but did not recognise our API key.
15
+ *
16
+ * Dataville's auth middleware never rejects outright — an unrecognised key
17
+ * falls through to anonymous access, which still returns data but under the
18
+ * much lower anonymous rate limit and without attributing usage to the
19
+ * account. Left unchecked that failure is invisible inside an MCP client, so
20
+ * we surface it explicitly instead of returning results that look fine.
21
+ */
22
+ export class DatavilleAuthError extends Error {
23
+ constructor(message) {
24
+ super(message);
25
+ this.name = "DatavilleAuthError";
26
+ }
27
+ }
13
28
  function getConfig() {
14
29
  const apiKey = process.env.DATAVILLE_API_KEY;
15
30
  if (!apiKey) {
@@ -38,5 +53,15 @@ export async function searchDataSource(source, keywords, params) {
38
53
  `Dataville API request failed with status ${response.status}`;
39
54
  throw new DatavilleApiError(response.status, message);
40
55
  }
56
+ // We always send an API key, so an "anonymous" account state means the key
57
+ // was not accepted. Fail loudly rather than silently serving anonymous-tier
58
+ // results that are neither attributed nor billed to the user's account.
59
+ if (body &&
60
+ typeof body === "object" &&
61
+ body.account_state === "anonymous") {
62
+ throw new DatavilleAuthError("Your DATAVILLE_API_KEY was not recognised, so this request fell back to anonymous access " +
63
+ "(much lower rate limits, and usage is not attributed to your account). " +
64
+ "Check the key in your MCP client config, or generate a new one at https://app.dataville.com/api-keys.");
65
+ }
41
66
  return body;
42
67
  }
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
4
  import { z } from "zod";
5
- import { searchDataSource, DatavilleApiError, VERSION } from "./client.js";
5
+ import { searchDataSource, VERSION } from "./client.js";
6
6
  import { DATAVILLE_SOURCES } from "./sources.js";
7
7
  const server = new McpServer({
8
8
  name: "dataville-mcp-server",
@@ -32,7 +32,7 @@ server.registerTool("search_dataville", {
32
32
  return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
33
33
  }
34
34
  catch (error) {
35
- const message = error instanceof DatavilleApiError ? error.message : String(error);
35
+ const message = error instanceof Error ? error.message : String(error);
36
36
  return { content: [{ type: "text", text: message }], isError: true };
37
37
  }
38
38
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataville/dataville-mcp",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "MCP server exposing Dataville's data source API as tools for MCP clients",
5
5
  "private": false,
6
6
  "license": "MIT",