@topolo/mcp 0.11.2 → 0.11.4
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/dispatch.js +12 -5
- package/dist/http.js +184 -177
- package/dist/index.js +84 -8
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
5
|
|
|
6
|
-
//
|
|
6
|
+
// ../../node_modules/.pnpm/@topolo+sdk@0.11.4/node_modules/@topolo/sdk/dist/index.js
|
|
7
7
|
function applyAuthHeaders(headers, credential) {
|
|
8
8
|
if (credential.kind === "api_key") {
|
|
9
9
|
headers.set("X-Api-Key", credential.apiKey);
|
|
@@ -1978,6 +1978,7 @@ function mergeSignals(a, b) {
|
|
|
1978
1978
|
function compactActionCatalogEntry(action) {
|
|
1979
1979
|
const required = Array.isArray(action.inputSchema["required"]) ? action.inputSchema["required"].filter((value) => typeof value === "string") : [];
|
|
1980
1980
|
const examples = action.agentContract?.examples ?? [];
|
|
1981
|
+
const example = compactExample(examples[0]?.input);
|
|
1981
1982
|
return {
|
|
1982
1983
|
actionId: action.actionId,
|
|
1983
1984
|
title: action.title,
|
|
@@ -1989,13 +1990,83 @@ function compactActionCatalogEntry(action) {
|
|
|
1989
1990
|
requiredPermission: action.requiredPermission,
|
|
1990
1991
|
requiredInput: required,
|
|
1991
1992
|
resourceType: action.agentContract?.resource?.kind ?? null,
|
|
1992
|
-
exampleInput:
|
|
1993
|
+
exampleInput: example.value,
|
|
1994
|
+
exampleInputAvailable: example.available,
|
|
1993
1995
|
docsUrl: action.agentContract?.docsUrl ?? null
|
|
1994
1996
|
};
|
|
1995
1997
|
}
|
|
1998
|
+
function compactExample(input) {
|
|
1999
|
+
if (!input) return { value: null, available: false };
|
|
2000
|
+
const serialized = JSON.stringify(input);
|
|
2001
|
+
if (serialized.length > 512) return { value: null, available: true };
|
|
2002
|
+
return { value: input, available: true };
|
|
2003
|
+
}
|
|
1996
2004
|
function compactActionValidation(actionId, validation) {
|
|
1997
2005
|
return { actionId, valid: validation.valid, errors: validation.errors };
|
|
1998
2006
|
}
|
|
2007
|
+
var ACTION_RESULT_MAX_DEPTH = 3;
|
|
2008
|
+
var ACTION_RESULT_MAX_KEYS = 12;
|
|
2009
|
+
var ACTION_RESULT_MAX_ORDINARY_KEYS = 5;
|
|
2010
|
+
var ACTION_RESULT_MAX_ITEMS = 3;
|
|
2011
|
+
var ACTION_RESULT_MAX_SCALARS = 60;
|
|
2012
|
+
var ACTION_RESULT_MAX_STRING = 256;
|
|
2013
|
+
function resultKeyPriority(key) {
|
|
2014
|
+
if (/^(id|requestId|status|state|url|slug|name|title|version)$/i.test(key)) return 0;
|
|
2015
|
+
if (/(Id|Ids|Url|Uri|Status|State|Count|Total|Version|CreatedAt|UpdatedAt)$/i.test(key)) return 1;
|
|
2016
|
+
return 2;
|
|
2017
|
+
}
|
|
2018
|
+
function compactResultValue(value, depth, budget) {
|
|
2019
|
+
if (value === null || typeof value === "boolean" || typeof value === "number") {
|
|
2020
|
+
budget.scalars += 1;
|
|
2021
|
+
return value;
|
|
2022
|
+
}
|
|
2023
|
+
if (typeof value === "string") {
|
|
2024
|
+
budget.scalars += 1;
|
|
2025
|
+
if (value.length <= ACTION_RESULT_MAX_STRING) return value;
|
|
2026
|
+
return `${value.slice(0, ACTION_RESULT_MAX_STRING)}\u2026 (${value.length} chars)`;
|
|
2027
|
+
}
|
|
2028
|
+
if (depth >= ACTION_RESULT_MAX_DEPTH || budget.scalars >= ACTION_RESULT_MAX_SCALARS) {
|
|
2029
|
+
return Array.isArray(value) ? { count: value.length, omitted: true } : { omitted: true };
|
|
2030
|
+
}
|
|
2031
|
+
if (Array.isArray(value)) {
|
|
2032
|
+
const items = value.slice(0, ACTION_RESULT_MAX_ITEMS).map((item) => compactResultValue(item, depth + 1, budget));
|
|
2033
|
+
return value.length > ACTION_RESULT_MAX_ITEMS ? { count: value.length, items, omittedItems: value.length - ACTION_RESULT_MAX_ITEMS } : items;
|
|
2034
|
+
}
|
|
2035
|
+
if (typeof value === "object") {
|
|
2036
|
+
const record = value;
|
|
2037
|
+
const allKeys = Object.keys(record);
|
|
2038
|
+
const ranked = allKeys.sort((left, right) => resultKeyPriority(left) - resultKeyPriority(right));
|
|
2039
|
+
const prioritized = ranked.filter((key) => resultKeyPriority(key) < 2);
|
|
2040
|
+
const ordinary = ranked.filter((key) => resultKeyPriority(key) === 2);
|
|
2041
|
+
const ordinaryLimit = depth === 0 ? ACTION_RESULT_MAX_ORDINARY_KEYS : prioritized.length ? 1 : ACTION_RESULT_MAX_ORDINARY_KEYS;
|
|
2042
|
+
const keys = [
|
|
2043
|
+
...prioritized,
|
|
2044
|
+
...ordinary.slice(0, ordinaryLimit)
|
|
2045
|
+
].slice(0, ACTION_RESULT_MAX_KEYS);
|
|
2046
|
+
const compact = Object.fromEntries(keys.map((key) => [key, compactResultValue(record[key], depth + 1, budget)]));
|
|
2047
|
+
if (allKeys.length > keys.length) compact["_omittedKeys"] = allKeys.length - keys.length;
|
|
2048
|
+
return compact;
|
|
2049
|
+
}
|
|
2050
|
+
budget.scalars += 1;
|
|
2051
|
+
return String(value);
|
|
2052
|
+
}
|
|
2053
|
+
function compactActionResult(actionId, result) {
|
|
2054
|
+
let normalized = result;
|
|
2055
|
+
if (typeof result === "string") {
|
|
2056
|
+
try {
|
|
2057
|
+
normalized = JSON.parse(result);
|
|
2058
|
+
} catch {
|
|
2059
|
+
normalized = result;
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
return { actionId, result: compactResultValue(normalized, 0, { scalars: 0 }) };
|
|
2063
|
+
}
|
|
2064
|
+
function preferExactActionMatches(actions, query) {
|
|
2065
|
+
const expected = query?.trim().toLowerCase();
|
|
2066
|
+
if (!expected) return actions;
|
|
2067
|
+
const exact = actions.filter((action) => [action.actionId, action.name, action.toolName].some((candidate) => candidate?.trim().toLowerCase() === expected));
|
|
2068
|
+
return exact.length ? exact : actions;
|
|
2069
|
+
}
|
|
1999
2070
|
function compactActionPlan(plan) {
|
|
2000
2071
|
return {
|
|
2001
2072
|
actionId: plan.action.actionId,
|
|
@@ -2203,7 +2274,7 @@ function createTopolo(options) {
|
|
|
2203
2274
|
};
|
|
2204
2275
|
}
|
|
2205
2276
|
|
|
2206
|
-
//
|
|
2277
|
+
// ../../node_modules/.pnpm/@topolo+sdk@0.11.4/node_modules/@topolo/sdk/dist/node/credential-store.js
|
|
2207
2278
|
import { mkdir, readFile, writeFile, chmod, rm, stat } from "fs/promises";
|
|
2208
2279
|
import { existsSync } from "fs";
|
|
2209
2280
|
import { homedir, platform } from "os";
|
|
@@ -2984,7 +3055,8 @@ var TOOLS = [
|
|
|
2984
3055
|
},
|
|
2985
3056
|
query: { type: "string" },
|
|
2986
3057
|
cursor: { type: "string" },
|
|
2987
|
-
limit: { type: "integer", minimum: 1, maximum: 100, default: 25 }
|
|
3058
|
+
limit: { type: "integer", minimum: 1, maximum: 100, default: 25 },
|
|
3059
|
+
detail: { type: "boolean", description: "Return full schemas and agent contracts. Defaults to compact action guidance." }
|
|
2988
3060
|
},
|
|
2989
3061
|
required: ["service"],
|
|
2990
3062
|
additionalProperties: false
|
|
@@ -2992,13 +3064,15 @@ var TOOLS = [
|
|
|
2992
3064
|
handler: async (topolo, args) => {
|
|
2993
3065
|
const service = typeof args["service"] === "string" ? args["service"].trim() : "";
|
|
2994
3066
|
if (!service) throw new TopoloMcpPublicError("service is required for bounded action discovery.");
|
|
3067
|
+
const query = typeof args["query"] === "string" ? args["query"] : void 0;
|
|
2995
3068
|
const result = await topolo.client.searchActions({
|
|
2996
3069
|
service,
|
|
2997
|
-
query
|
|
3070
|
+
query,
|
|
2998
3071
|
cursor: typeof args["cursor"] === "string" ? args["cursor"] : void 0,
|
|
2999
3072
|
limit: typeof args["limit"] === "number" ? args["limit"] : void 0
|
|
3000
3073
|
});
|
|
3001
|
-
|
|
3074
|
+
const actions = preferExactActionMatches(result.actions, query);
|
|
3075
|
+
return args["detail"] === true ? { ...result, actions } : { actions: actions.map(compactActionCatalogEntry), page: result.page };
|
|
3002
3076
|
}
|
|
3003
3077
|
},
|
|
3004
3078
|
{
|
|
@@ -3086,7 +3160,8 @@ var TOOLS = [
|
|
|
3086
3160
|
input: { type: "object", additionalProperties: true },
|
|
3087
3161
|
resourceType: { type: "string", description: "Optional resource-scoping alias published in the app resource catalog (e.g. workspace, brand, merchant)." },
|
|
3088
3162
|
resourceId: { type: "string", description: "Resource id. Required when resourceType is provided." },
|
|
3089
|
-
confirm: { type: "boolean" }
|
|
3163
|
+
confirm: { type: "boolean" },
|
|
3164
|
+
detail: { type: "boolean", description: "Return the complete action response. Defaults to a bounded agent projection." }
|
|
3090
3165
|
},
|
|
3091
3166
|
required: ["actionId"],
|
|
3092
3167
|
additionalProperties: false
|
|
@@ -3096,7 +3171,7 @@ var TOOLS = [
|
|
|
3096
3171
|
if (!actionId) throw new TopoloMcpPublicError("actionId is required.");
|
|
3097
3172
|
const input = coerceObjectParam(args["input"], "input");
|
|
3098
3173
|
const resource = optionalResourceContext(args);
|
|
3099
|
-
|
|
3174
|
+
const result = await topolo.client.callAction(
|
|
3100
3175
|
actionId,
|
|
3101
3176
|
input,
|
|
3102
3177
|
{
|
|
@@ -3104,6 +3179,7 @@ var TOOLS = [
|
|
|
3104
3179
|
...resource ? { resource } : {}
|
|
3105
3180
|
}
|
|
3106
3181
|
);
|
|
3182
|
+
return args["detail"] === true ? result : compactActionResult(actionId, result);
|
|
3107
3183
|
}
|
|
3108
3184
|
},
|
|
3109
3185
|
{
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@topolo/mcp",
|
|
3
|
-
"version": "0.11.
|
|
4
|
-
"topoloPublishedVersion": "0.11.
|
|
3
|
+
"version": "0.11.4",
|
|
4
|
+
"topoloPublishedVersion": "0.11.4",
|
|
5
5
|
"description": "Model Context Protocol server for the Topolo platform. Exposes scope-gated tools that third-party agents (Claude, Codex, etc.) can call natively.",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"author": "Topolo",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
38
|
-
"@topolo/sdk": "0.11.
|
|
38
|
+
"@topolo/sdk": "0.11.4"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^20.12.0",
|