MCPcopy Index your code
hub / github.com/simstudioai/sim / getMcpServerToolMetadataUsageRows

Function getMcpServerToolMetadataUsageRows

apps/sim/lib/mcp/tool-limits.ts:129–156  ·  view source on GitHub ↗
(
  tx: DbOrTx,
  serverId: string,
  excludeToolId?: string
)

Source from the content-addressed store, hash-verified

127}
128
129export async function getMcpServerToolMetadataUsageRows(
130 tx: DbOrTx,
131 serverId: string,
132 excludeToolId?: string
133): Promise<McpToolMetadataUsageRow[]> {
134 const rows = await tx
135 .select({
136 id: workflowMcpTool.id,
137 toolNameBytes: sql<number>`octet_length(${workflowMcpTool.toolName})`,
138 toolDescriptionBytes: sql<number>`coalesce(octet_length(${workflowMcpTool.toolDescription}), 0)`,
139 parameterSchemaBytes: sql<number>`octet_length(${workflowMcpTool.parameterSchema}::text)`,
140 })
141 .from(workflowMcpTool)
142 .where(
143 and(
144 eq(workflowMcpTool.serverId, serverId),
145 isNull(workflowMcpTool.archivedAt),
146 excludeToolId ? ne(workflowMcpTool.id, excludeToolId) : undefined
147 )
148 )
149
150 return rows.map((row) => ({
151 id: row.id,
152 toolNameBytes: Number(row.toolNameBytes) || 0,
153 toolDescriptionBytes: Number(row.toolDescriptionBytes) || 0,
154 parameterSchemaBytes: Number(row.parameterSchemaBytes) || 0,
155 }))
156}
157
158export function validateMcpToolMetadataForStorage(metadata: {
159 toolName?: string | null

Callers 3

syncMcpToolsForWorkflowFunction · 0.90

Calls 1

eqFunction · 0.50

Tested by

no test coverage detected