Skip to content

Commit ef11915

Browse files
committed
fix: align schema tool interfaces with BM MCP response format
SchemaInferResult and SchemaDiffResult interfaces used 'field' and 'frequency' but BM MCP returns 'name' and 'percentage'. This caused NaN% and undefined in schema-infer and schema-diff tool output. Updated interfaces, formatters, and tests to match actual BM response.
1 parent 0e00488 commit ef11915

File tree

5 files changed

+16
-11
lines changed

5 files changed

+16
-11
lines changed

bm-client.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,14 @@ export interface SchemaInferResult {
121121
entity_type: string
122122
notes_analyzed: number
123123
field_frequencies: Array<{
124-
field: string
125-
frequency: number
124+
name: string
125+
percentage: number
126126
count: number
127+
total: number
128+
source: string
129+
sample_values?: string[]
130+
is_array?: boolean
131+
target_type?: string | null
127132
}>
128133
suggested_schema: Record<string, unknown>
129134
suggested_required: string[]
@@ -134,8 +139,8 @@ export interface SchemaInferResult {
134139
export interface SchemaDiffResult {
135140
entity_type: string
136141
schema_found: boolean
137-
new_fields: Array<{ field: string; frequency: number }>
138-
dropped_fields: Array<{ field: string; declared_in: string }>
142+
new_fields: Array<{ name: string; source: string; count: number; total: number; percentage: number }>
143+
dropped_fields: Array<{ name: string; source: string; declared_in?: string }>
139144
cardinality_changes: string[]
140145
}
141146

tools/schema-diff.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ describe("schema-diff tool", () => {
4141
;(mockClient.schemaDiff as jest.MockedFunction<any>).mockResolvedValue({
4242
entity_type: "person",
4343
schema_found: true,
44-
new_fields: [{ field: "phone", frequency: 0.6 }],
45-
dropped_fields: [{ field: "fax", declared_in: "schema" }],
44+
new_fields: [{ name: "phone", source: "observation", count: 6, total: 10, percentage: 0.6 }],
45+
dropped_fields: [{ name: "fax", source: "observation", declared_in: "schema" }],
4646
cardinality_changes: [],
4747
})
4848

tools/schema-diff.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,15 @@ export function registerSchemaDiffTool(
6262
lines.push("", "### New Fields (in notes, not in schema)")
6363
for (const f of result.new_fields) {
6464
lines.push(
65-
`- **${f.field}** — ${(f.frequency * 100).toFixed(0)}% of notes`,
65+
`- **${f.name}** — ${(f.percentage * 100).toFixed(0)}% of notes`,
6666
)
6767
}
6868
}
6969

7070
if (result.dropped_fields.length > 0) {
7171
lines.push("", "### Dropped Fields (in schema, not in notes)")
7272
for (const f of result.dropped_fields) {
73-
lines.push(`- **${f.field}** — declared in ${f.declared_in}`)
73+
lines.push(`- **${f.name}** — declared in ${f.declared_in}`)
7474
}
7575
}
7676

tools/schema-infer.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ describe("schema-infer tool", () => {
4242
entity_type: "person",
4343
notes_analyzed: 12,
4444
field_frequencies: [
45-
{ field: "name", frequency: 1.0, count: 12 },
46-
{ field: "email", frequency: 0.75, count: 9 },
45+
{ name: "name", percentage: 1.0, count: 12, total: 12, source: "observation" },
46+
{ name: "email", percentage: 0.75, count: 9, total: 12, source: "observation" },
4747
],
4848
suggested_schema: { name: "string", "email?": "string" },
4949
suggested_required: ["name"],

tools/schema-infer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function registerSchemaInferTool(
6666
lines.push("", "### Field Frequencies")
6767
for (const f of result.field_frequencies) {
6868
lines.push(
69-
`- **${f.field}** — ${(f.frequency * 100).toFixed(0)}% (${f.count} notes)`,
69+
`- **${f.name}** — ${(f.percentage * 100).toFixed(0)}% (${f.count} notes)`,
7070
)
7171
}
7272
}

0 commit comments

Comments
 (0)