added mcp tests for media

This commit is contained in:
dswbx
2025-08-12 20:57:13 +02:00
parent bd3d2ea900
commit a6ed74d904
5 changed files with 112 additions and 14 deletions

View File

@@ -177,7 +177,6 @@ export class SchemaObject<Schema extends TSchema = TSchema> {
this.throwIfRestricted(partial);
// overwrite arrays and primitives, only deep merge objects
// @ts-ignore
const config = set(current, path, value);

View File

@@ -39,6 +39,7 @@ export function buildMediaSchema() {
},
{ default: {} },
),
// @todo: currently cannot be updated partially using mcp
adapter: $schema(
"config_media_adapter",
s.anyOf(Object.values(adapterSchemaObject)),

View File

@@ -50,12 +50,28 @@ export const $schema = <
{
...mcp.getToolOptions("update"),
inputSchema: s.strictObject({
full: s.boolean({ default: false }).optional(),
value: schema as any,
return_config: s.boolean({ default: false }).optional(),
secrets: s.boolean({ default: false }).optional(),
}),
},
async (params, ctx: AppToolHandlerCtx) => {
return ctx.json(params);
const { value, return_config, secrets } = params;
const [module_name, ...rest] = node.instancePath;
await ctx.context.app.mutateConfig(module_name as any).overwrite(rest, value);
let config: any = undefined;
if (return_config) {
const configs = ctx.context.app.toJSON(secrets);
config = getPath(configs, node.instancePath);
}
return ctx.json({
success: true,
module: module_name,
config,
});
},
);
};