@snokam/mcp-api 1.21.1 → 2.0.1
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/auth.d.ts +0 -15
- package/dist/auth.js +17 -61
- package/dist/builtin-tools.d.ts +109 -0
- package/dist/builtin-tools.js +200 -0
- package/dist/execute-call.d.ts +5 -0
- package/dist/execute-call.js +45 -0
- package/dist/index.d.ts +0 -7
- package/dist/index.js +16 -311
- package/dist/openapi-loader.d.ts +1 -14
- package/dist/openapi-loader.js +27 -50
- package/dist/requirements.d.ts +10 -0
- package/dist/requirements.js +92 -0
- package/dist/state.d.ts +14 -0
- package/dist/state.js +66 -0
- package/dist/tool-schema.d.ts +2 -0
- package/dist/tool-schema.js +42 -0
- package/package.json +3 -3
- package/specs/production/accounting.json +2629 -1754
- package/specs/production/blog.json +1608 -1
- package/specs/production/broker.json +52 -24
- package/specs/production/chatgpt.json +299 -17
- package/specs/production/employees.json +2979 -299
- package/specs/production/events.json +366 -52
- package/specs/production/notifications.json +390 -13
- package/specs/production/office.json +818 -836
- package/specs/production/recruitment.json +3635 -1
- package/specs/production/sales.json +5088 -393
- package/specs/production/sanity.json +29008 -15539
- package/specs/production/sync.json +116 -20
- package/specs/production/webshop.json +38 -18
- package/specs/test/accounting.json +2629 -1754
- package/specs/test/blog.json +1608 -1
- package/specs/test/broker.json +52 -24
- package/specs/test/chatgpt.json +299 -17
- package/specs/test/employees.json +2979 -299
- package/specs/test/events.json +366 -52
- package/specs/test/notifications.json +390 -13
- package/specs/test/office.json +818 -836
- package/specs/test/recruitment.json +3635 -1
- package/specs/test/sales.json +5088 -393
- package/specs/test/sanity.json +29008 -15539
- package/specs/test/sync.json +116 -20
- package/specs/test/webshop.json +38 -18
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,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,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snokam/mcp-api",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "MCP server exposing Snokam backend APIs as tools for Claude Code and other MCP clients",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@azure/identity": "^4.13.1",
|
|
25
25
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
26
|
-
"zod": "^4.3
|
|
26
|
+
"zod": "^4.4.3"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@types/node": "^
|
|
29
|
+
"@types/node": "^26.1.1",
|
|
30
30
|
"typescript": "~6.0.2"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|