MCPcopy Create free account
hub / github.com/continuedev/continue / coerceArgsToSchema

Function coerceArgsToSchema

core/tools/parseArgs.ts:34–63  ·  view source on GitHub ↗
(
  args: Record<string, any>,
  schema?: Record<string, any>,
)

Source from the content-addressed store, hash-verified

32 * any values that should be strings.
33 */
34export function coerceArgsToSchema(
35 args: Record<string, any>,
36 schema?: Record<string, any>,
37): Record<string, any> {
38 if (!schema?.properties) {
39 return args;
40 }
41
42 const coerced = { ...args };
43 for (const [key, value] of Object.entries(coerced)) {
44 const propSchema = schema.properties[key];
45 if (!propSchema) {
46 continue;
47 }
48
49 if (
50 propSchema.type === "string" &&
51 typeof value === "object" &&
52 value !== null
53 ) {
54 try {
55 coerced[key] = JSON.stringify(value);
56 } catch {
57 // leave as-is if stringify fails
58 }
59 }
60 }
61
62 return coerced;
63}
64
65export function getStringArg(
66 args: any,

Callers 2

callToolFromUriFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected