@snokam/mcp-api 2.61.1 → 3.0.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.
Files changed (43) hide show
  1. package/dist/auth.d.ts +0 -15
  2. package/dist/auth.js +17 -61
  3. package/dist/builtin-tools.d.ts +109 -0
  4. package/dist/builtin-tools.js +200 -0
  5. package/dist/execute-call.d.ts +5 -0
  6. package/dist/execute-call.js +45 -0
  7. package/dist/index.d.ts +0 -7
  8. package/dist/index.js +16 -311
  9. package/dist/openapi-loader.d.ts +1 -14
  10. package/dist/openapi-loader.js +27 -50
  11. package/dist/requirements.d.ts +10 -0
  12. package/dist/requirements.js +92 -0
  13. package/dist/state.d.ts +14 -0
  14. package/dist/state.js +66 -0
  15. package/dist/tool-schema.d.ts +2 -0
  16. package/dist/tool-schema.js +42 -0
  17. package/package.json +8 -3
  18. package/specs/production/accounting.json +2931 -2321
  19. package/specs/production/blog.json +747 -1497
  20. package/specs/production/broker.json +54 -25
  21. package/specs/production/chatgpt.json +570 -207
  22. package/specs/production/employees.json +2697 -1823
  23. package/specs/production/events.json +615 -974
  24. package/specs/production/notifications.json +329 -15
  25. package/specs/production/office.json +818 -836
  26. package/specs/production/recruitment.json +1883 -1207
  27. package/specs/production/sales.json +2909 -1172
  28. package/specs/production/sanity.json +47384 -16348
  29. package/specs/production/sync.json +116 -20
  30. package/specs/production/webshop.json +37 -17
  31. package/specs/test/accounting.json +2931 -2321
  32. package/specs/test/blog.json +747 -1497
  33. package/specs/test/broker.json +54 -25
  34. package/specs/test/chatgpt.json +570 -207
  35. package/specs/test/employees.json +2697 -1823
  36. package/specs/test/events.json +615 -974
  37. package/specs/test/notifications.json +329 -15
  38. package/specs/test/office.json +818 -836
  39. package/specs/test/recruitment.json +1883 -1207
  40. package/specs/test/sales.json +2909 -1172
  41. package/specs/test/sanity.json +47384 -16348
  42. package/specs/test/sync.json +116 -20
  43. package/specs/test/webshop.json +37 -17
package/dist/state.js ADDED
@@ -0,0 +1,66 @@
1
+ import { fetchSpecs } from "./openapi-loader.js";
2
+ export let currentEnvironment = process.env.SNOKAM_ENVIRONMENT ?? "production";
3
+ export let apiHostOverride = null;
4
+ export let endpoints = [];
5
+ export let endpointsByTool = new Map();
6
+ export const serviceUrlOverrides = new Map();
7
+ export function setApiHostOverride(host) {
8
+ apiHostOverride = host;
9
+ }
10
+ export function resolveApiHost(environment) {
11
+ const explicit = process.env.SNOKAM_API_HOST;
12
+ if (explicit)
13
+ return normalizeDomain(explicit);
14
+ const suffix = environment === "test" ? "test.snosky.no" : "snosky.no";
15
+ const business = process.env.SNOKAM_BUSINESS;
16
+ return business ? `${business}.${suffix}` : suffix;
17
+ }
18
+ export function activeApiHost() {
19
+ return apiHostOverride ?? resolveApiHost(currentEnvironment);
20
+ }
21
+ let reload = null;
22
+ export async function settled() {
23
+ while (reload)
24
+ await reload;
25
+ }
26
+ export function loadEndpoints(environment) {
27
+ reload = (async () => {
28
+ await load(environment);
29
+ reload = null;
30
+ })();
31
+ return reload;
32
+ }
33
+ async function load(environment) {
34
+ currentEnvironment = environment;
35
+ endpoints = await fetchSpecs(environment, activeApiHost());
36
+ endpointsByTool = new Map();
37
+ for (const ep of endpoints) {
38
+ endpointsByTool.set(ep.toolName, ep);
39
+ }
40
+ applyUrlOverrides();
41
+ }
42
+ function applyUrlOverrides() {
43
+ for (const ep of endpoints) {
44
+ const override = serviceUrlOverrides.get(ep.service);
45
+ if (override) {
46
+ ep.baseUrl = override;
47
+ }
48
+ }
49
+ }
50
+ export function normalizeDomain(raw) {
51
+ return raw
52
+ .trim()
53
+ .replace(/^https?:\/\//, "")
54
+ .replace(/\/$/, "");
55
+ }
56
+ export function rebuildEndpointsByTool() {
57
+ endpointsByTool = new Map();
58
+ for (const ep of endpoints) {
59
+ endpointsByTool.set(ep.toolName, ep);
60
+ }
61
+ }
62
+ export function replaceServiceEndpoints(service, freshEndpoints) {
63
+ endpoints = endpoints.filter((ep) => ep.service !== service);
64
+ endpoints.push(...freshEndpoints);
65
+ rebuildEndpointsByTool();
66
+ }
@@ -0,0 +1,2 @@
1
+ import { type ApiEndpoint } from "./openapi-loader.js";
2
+ export declare function buildInputSchema(endpoint: ApiEndpoint): Record<string, unknown>;
@@ -0,0 +1,42 @@
1
+ export function buildInputSchema(endpoint) {
2
+ const properties = {};
3
+ const required = [];
4
+ for (const param of endpoint.parameters) {
5
+ const prop = {};
6
+ if (param.schema?.type)
7
+ prop.type = param.schema.type;
8
+ if (param.schema?.enum)
9
+ prop.enum = param.schema.enum;
10
+ if (param.schema?.format)
11
+ prop.format = param.schema.format;
12
+ if (param.schema?.items)
13
+ prop.items = param.schema.items;
14
+ if (param.description)
15
+ prop.description = param.description;
16
+ if (!prop.type)
17
+ prop.type = "string";
18
+ properties[param.name] = prop;
19
+ if (param.required)
20
+ required.push(param.name);
21
+ }
22
+ if (endpoint.requestBody) {
23
+ properties.body = {
24
+ type: "object",
25
+ description: endpoint.requestBody.description ?? "Request body",
26
+ };
27
+ const jsonContent = endpoint.requestBody.content?.["application/json"];
28
+ if (jsonContent?.schema) {
29
+ properties.body = {
30
+ ...properties.body,
31
+ ...jsonContent.schema,
32
+ };
33
+ }
34
+ if (endpoint.requestBody.required)
35
+ required.push("body");
36
+ }
37
+ return {
38
+ type: "object",
39
+ properties,
40
+ required: required.length > 0 ? required : undefined,
41
+ };
42
+ }
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "@snokam/mcp-api",
3
- "version": "2.61.1",
3
+ "version": "3.0.0",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "git+https://github.com/snokam/monorepo.git",
7
+ "directory": "mcp/@snokam/api-mcp"
8
+ },
4
9
  "description": "MCP server exposing Snokam backend APIs as tools for Claude Code and other MCP clients",
5
10
  "type": "module",
6
11
  "bin": {
@@ -23,10 +28,10 @@
23
28
  "dependencies": {
24
29
  "@azure/identity": "^4.13.1",
25
30
  "@modelcontextprotocol/sdk": "^1.29.0",
26
- "zod": "^4.3.6"
31
+ "zod": "^4.4.3"
27
32
  },
28
33
  "devDependencies": {
29
- "@types/node": "^25.5.0",
34
+ "@types/node": "^26.1.1",
30
35
  "typescript": "~6.0.2"
31
36
  },
32
37
  "publishConfig": {