@sodiumhq/mcp-pm 0.1.0-beta.2599 → 0.1.0-beta.2600
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/index.js +30 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
5
|
import { randomUUID } from "node:crypto";
|
|
@@ -952,14 +953,32 @@ var SodiumApiError = class extends Error {
|
|
|
952
953
|
this.name = "SodiumApiError";
|
|
953
954
|
}
|
|
954
955
|
};
|
|
956
|
+
function sanitizeToken(value) {
|
|
957
|
+
return value.replace(/[\s()\/]+/g, "-").replace(/[^\w.\-]/g, "") || "unknown";
|
|
958
|
+
}
|
|
955
959
|
var SodiumApiClient = class {
|
|
956
|
-
|
|
960
|
+
serverVersion;
|
|
961
|
+
mcpClient = null;
|
|
962
|
+
constructor(ctx, options) {
|
|
957
963
|
this.ctx = ctx;
|
|
964
|
+
this.serverVersion = options.serverVersion;
|
|
958
965
|
client.setConfig({
|
|
959
966
|
baseUrl: ctx.baseUrl,
|
|
960
|
-
headers: {
|
|
967
|
+
headers: {
|
|
968
|
+
"x-api-key": ctx.apiKey,
|
|
969
|
+
"User-Agent": this.buildUserAgent()
|
|
970
|
+
}
|
|
961
971
|
});
|
|
962
972
|
}
|
|
973
|
+
setMcpClientInfo(info) {
|
|
974
|
+
this.mcpClient = info;
|
|
975
|
+
client.setConfig({ headers: { "User-Agent": this.buildUserAgent() } });
|
|
976
|
+
}
|
|
977
|
+
buildUserAgent() {
|
|
978
|
+
const base = `sodiumhq-mcp-pm/${this.serverVersion}`;
|
|
979
|
+
if (!this.mcpClient) return base;
|
|
980
|
+
return `${base} (client=${sanitizeToken(this.mcpClient.name)}/${sanitizeToken(this.mcpClient.version)})`;
|
|
981
|
+
}
|
|
963
982
|
async getPracticeDetails() {
|
|
964
983
|
const correlationId = randomUUID();
|
|
965
984
|
const { data, error, response } = await getPracticeDetails({
|
|
@@ -2104,7 +2123,7 @@ function describeFilters(args) {
|
|
|
2104
2123
|
//#endregion
|
|
2105
2124
|
//#region ../mcp-core/src/server.ts
|
|
2106
2125
|
async function buildServer(config) {
|
|
2107
|
-
const api = new SodiumApiClient(config.context);
|
|
2126
|
+
const api = new SodiumApiClient(config.context, { serverVersion: config.serverVersion });
|
|
2108
2127
|
const instructions = await buildInstructions(api);
|
|
2109
2128
|
const server = new McpServer({
|
|
2110
2129
|
name: config.serverName,
|
|
@@ -2113,6 +2132,13 @@ async function buildServer(config) {
|
|
|
2113
2132
|
instructions,
|
|
2114
2133
|
capabilities: { tools: {} }
|
|
2115
2134
|
});
|
|
2135
|
+
server.server.oninitialized = () => {
|
|
2136
|
+
const info = server.server.getClientVersion();
|
|
2137
|
+
if (info?.name && info?.version) api.setMcpClientInfo({
|
|
2138
|
+
name: info.name,
|
|
2139
|
+
version: info.version
|
|
2140
|
+
});
|
|
2141
|
+
};
|
|
2116
2142
|
server.registerTool("get_practice_details", {
|
|
2117
2143
|
title: "Get practice details",
|
|
2118
2144
|
description: "Get a consolidated overview of the practice including name, contact details, client/service/user counts, connections, and settings. Use this when the user asks about their practice, tenant, or wants a summary of their account.",
|
|
@@ -2231,7 +2257,7 @@ function loadContext() {
|
|
|
2231
2257
|
}
|
|
2232
2258
|
//#endregion
|
|
2233
2259
|
//#region src/index.ts
|
|
2234
|
-
const VERSION = "
|
|
2260
|
+
const VERSION = createRequire(import.meta.url)("../package.json").version;
|
|
2235
2261
|
async function main() {
|
|
2236
2262
|
const context = loadContext();
|
|
2237
2263
|
const server = await buildServer({
|