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

Function enrichTableToolSchema

apps/sim/tools/schema-enrichers.ts:33–72  ·  view source on GitHub ↗
(
  tableId: string,
  toolId: string,
  originalSchema: {
    type: 'object'
    properties: Record<string, unknown>
    required: string[]
  },
  originalDescription: string
)

Source from the content-addressed store, hash-verified

31}
32
33export async function enrichTableToolSchema(
34 tableId: string,
35 toolId: string,
36 originalSchema: {
37 type: 'object'
38 properties: Record<string, unknown>
39 required: string[]
40 },
41 originalDescription: string
42): Promise<{
43 description: string
44 parameters: {
45 type: 'object'
46 properties: Record<string, unknown>
47 required: string[]
48 }
49} | null> {
50 const tableSchema = await fetchTableSchema(tableId)
51
52 if (!tableSchema) {
53 return null
54 }
55
56 const enrichedDescription = enrichTableToolDescription(originalDescription, tableSchema, toolId)
57 const enrichedParams = enrichTableToolParameters(
58 { properties: originalSchema.properties, required: originalSchema.required },
59 tableSchema,
60 toolId
61 )
62
63 return {
64 description: enrichedDescription,
65 parameters: {
66 type: 'object',
67 properties: enrichedParams.properties,
68 required:
69 enrichedParams.required.length > 0 ? enrichedParams.required : originalSchema.required,
70 },
71 }
72}
73
74interface TagDefinition {
75 id: string

Callers 7

insert_row.tsFile · 0.90
update_row.tsFile · 0.90
upsert_row.tsFile · 0.90
query_rows.tsFile · 0.90

Calls 3

fetchTableSchemaFunction · 0.85

Tested by

no test coverage detected