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

Function validateMcpToolMetadataForStorage

apps/sim/lib/mcp/tool-limits.ts:158–185  ·  view source on GitHub ↗
(metadata: {
  toolName?: string | null
  toolDescription?: string | null
  parameterSchema?: unknown
})

Source from the content-addressed store, hash-verified

156}
157
158export function validateMcpToolMetadataForStorage(metadata: {
159 toolName?: string | null
160 toolDescription?: string | null
161 parameterSchema?: unknown
162}): string | null {
163 if (metadata.toolName && utf8Size(metadata.toolName) > MAX_MCP_TOOL_NAME_BYTES) {
164 return `Tool name exceeds maximum size of ${MAX_MCP_TOOL_NAME_BYTES} bytes`
165 }
166
167 if (
168 metadata.toolDescription &&
169 utf8Size(metadata.toolDescription) > MAX_MCP_TOOL_DESCRIPTION_BYTES
170 ) {
171 return `Tool description exceeds maximum size of ${MAX_MCP_TOOL_DESCRIPTION_BYTES} bytes`
172 }
173
174 if (metadata.parameterSchema !== undefined) {
175 const parameterSchemaBytes = jsonSize(metadata.parameterSchema)
176 if (parameterSchemaBytes === null) {
177 return 'Tool parameter schema must be JSON serializable'
178 }
179 if (parameterSchemaBytes > MAX_MCP_PARAMETER_SCHEMA_BYTES) {
180 return `Tool parameter schema exceeds maximum size of ${MAX_MCP_PARAMETER_SCHEMA_BYTES} bytes`
181 }
182 }
183
184 return null
185}

Callers 3

syncMcpToolsForWorkflowFunction · 0.90
prepareWorkflowMcpToolFunction · 0.90

Calls 2

utf8SizeFunction · 0.85
jsonSizeFunction · 0.85

Tested by

no test coverage detected