Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(outbound): normalize flattened ACP prefixes and raw API pattern

Will Ren45605c8f9bda
diff --git a/packages/phone-protocol/src/outbound.ts b/packages/phone-protocol/src/outbound.ts
index d6accf6368..b845fd2874 100644
--- a/packages/phone-protocol/src/outbound.ts
+++ b/packages/phone-protocol/src/outbound.ts
@@ -40,7 +40,7 @@ const CREATE_VERBS = new Set(["CREATE", "CREATION", "ADD", "NEW", "MAKE"]);
const SENT_NOUNS = new Set(["MESSAGE", "COMMENT", "POST", "EMAIL", "MAIL", "INVOICE", "PAYMENT", "REFUND", "REPLY", "TWEET", "DM", "CALL"]);
/** Telnyx's hosted server reaches its whole API through one tool, so any call of it may ring, text or buy. */
-const RAW_API_ACTION = /^mcp__.+__invoke_api_endpoint$/;
+const RAW_API_ACTION = /^mcp__.+__invoke_api_endpoint$|^mcp_.+_invoke_api_endpoint$/;
/** A read verb first means the rest of the name is what is being read:
* REDDIT_GET_POST fetches a post, it does not post. */
@@ -67,6 +67,15 @@ function actionTokens(name: string): string[] {
const [, server = "", ...rest] = name.split("__");
action = rest.join("_");
if (isConnectedAppsServer(server)) return actionTokens(action);
+ } else if (/^mcp_/i.test(name)) {
+ const flatConnected = /^mcp_(?:composio|own_apps)_(.+)$/i.exec(name);
+ if (flatConnected) return actionTokens(flatConnected[1]!);
+ const flatMcp = /^mcp_([^_]+)_(.+)$/i.exec(name);
+ if (flatMcp) {
+ const [, server, rest] = flatMcp;
+ if (isConnectedAppsServer(server!)) return actionTokens(rest!);
+ action = rest!;
+ }
} else if (/^(?:[A-Z][A-Z0-9]*|_[A-Z0-9]+)_[A-Z0-9_]+$/.test(name)) {
const start = name.startsWith("_") ? 1 : 0;
action = name.slice(name.indexOf("_", start) + 1);
@@ -82,13 +91,13 @@ function actionTokens(name: string): string[] {
* narrower than "not outbound": updates, deletes and other writes do not
* become reads merely because they send nothing to another person. */
export function isReadOnlyTool(name: string): boolean {
- if (KNOWN_READ_SLUGS.has(name.replace(/^mcp__(?:composio|own_apps)__/, ""))) return true;
+ if (KNOWN_READ_SLUGS.has(name.replace(/^mcp(?:__|_)(?:composio|own_apps)(?:__|_)/, ""))) return true;
const tokens = actionTokens(name);
return tokens.length > 0 && READ_VERBS.has(tokens[0]);
}
/** The built-in agents server's X research tools only read X: x_post reads a post, it does not post one. */
-const AGENTS_X_READS = /^(?:mcp__agents__|agents__|agents_)?x_(?:search|user_posts|post|profile)$/;
+const AGENTS_X_READS = /^(?:mcp__agents__|mcp_agents_|agents__|agents_)?x_(?:search|user_posts|post|profile)$/;
const GENERIC_SUMMARY_MCP = /^Run\s+(mcp_[A-Za-z0-9_.:-]+)\b/i;
diff --git a/shared/outbound.test.ts b/shared/outbound.test.ts
index 66e676df92..e5bc5b303b 100644
--- a/shared/outbound.test.ts
+++ b/shared/outbound.test.ts
@@ -215,6 +215,11 @@ describe("outboundCallsIn", () => {
expect(effectiveToolName("bash", "Run mcp_composio_GMAIL_SEND_EMAIL")).toBe("bash");
expect(isOutboundTool("other", "Run mcp_composio_GMAIL_SEND_EMAIL")).toBe(true);
expect(isOutboundTool("other", "Run mcp_composio_COMPOSIO_PROXY_EXECUTE")).toBe(true);
+ expect(isOutboundTool("other", "Run mcp_telnyx_invoke_api_endpoint")).toBe(true);
+ expect(isOutboundTool("other", "Run mcp_telnyx_list_numbers")).toBe(false);
+ expect(isReadOnlyTool("mcp_composio_REDDIT_GET_POST")).toBe(true);
+ expect(isReadOnlyTool("mcp_composio_GOOGLECALENDAR_EVENTS_LIST")).toBe(true);
+ expect(isOutboundTool("other", "Run mcp_composio_REDDIT_GET_POST")).toBe(false);
expect(isOutboundTool("other", "Run mcp_computer_click")).toBe(false);
});
});