fix(mcp): clarify routing and advertise input examples
This commit is contained in:
@@ -29,7 +29,7 @@ import {
|
||||
import { installDynamicToolAvailability } from "./DynamicToolAvailability.js";
|
||||
|
||||
const TARGET_FREE_INSTRUCTIONS =
|
||||
"REA analyzes shipped artifacts. Route: ASAR/JavaScript -> analyze_javascript_application (configured root); archive/package -> inspect_artifact; managed PE/CLI -> inspect_managed_artifact; passive browser/Electron -> list_browser_targets/list_electron_targets; approved browser interaction -> capture_browser_scenario; Node/Electron Inspector -> list_javascript_runtime_targets; native binary/database -> open_binary, then binary_overview. Check binary_session policy. Start with summaries and cite Evidence IDs. Never repeat identical analysis or read full Evidence without need.";
|
||||
"ASAR/JavaScript -> analyze_javascript_application; archive/package -> open_binary(path), then inspect_artifact/inventory_artifact (active target); managed PE/CLI -> inspect_managed_artifact; passive browser/Electron -> list_browser_targets/list_electron_targets; approved browser interaction -> capture_browser_scenario; Node/Electron Inspector -> list_javascript_runtime_targets; native binary/database -> open_binary, then binary_overview. Start with binary_session; call only tools in tools/list. Hidden routes: binary_session detail=capabilities. Use summaries, cite Evidence IDs. Never repeat identical analysis or read full Evidence.";
|
||||
|
||||
const ACTIVE_TARGET_INSTRUCTIONS =
|
||||
"REA analyzes the active reverse-engineering target. Start native analysis with binary_overview, then narrow with analyze_function, literal search, callers, callees, and xrefs. Prefer summary views, never repeat an identical call, and read full Evidence only when the task requires it.";
|
||||
|
||||
@@ -184,7 +184,7 @@ const recommendedActions = (
|
||||
: []),
|
||||
...(!open
|
||||
? [
|
||||
"Route the supplied target directly: ASAR/JavaScript to analyze_javascript_application, unfamiliar packages to inspect_artifact, managed PE/CLI to inspect_managed_artifact, browser/Electron runtimes to their list-target tools, and native binaries to open_binary.",
|
||||
"For a supplied target, route by format: ASAR/JavaScript to analyze_javascript_application; archive/package to open_binary(path), then inspect_artifact or inventory_artifact on the active target; managed PE/CLI to inspect_managed_artifact; browser/Electron runtimes to their list-target tools; native binaries to open_binary.",
|
||||
]
|
||||
: [
|
||||
"Continue from the active target with binary_overview or a bounded target-specific query.",
|
||||
|
||||
@@ -15,7 +15,7 @@ const ADVERTISED_OUTPUT_SCHEMAS = new WeakMap<
|
||||
export const toolRegistrationOptions = (contract: ToolContract) => ({
|
||||
title: contract.title,
|
||||
description: contract.description,
|
||||
inputSchema: advertisedInputSchema(contract.inputSchema),
|
||||
inputSchema: advertisedInputSchema(contract),
|
||||
outputSchema: advertisedOutputSchema(contract.outputSchema),
|
||||
annotations: contract.annotations,
|
||||
});
|
||||
@@ -25,14 +25,14 @@ export const toolRegistrationOptions = (contract: ToolContract) => ({
|
||||
* The SDK otherwise converts validation failures to text-only JSON-RPC errors
|
||||
* before REA can return its stable structured error envelope.
|
||||
*/
|
||||
const advertisedInputSchema = (schema: z.ZodObject) => ({
|
||||
const advertisedInputSchema = (contract: ToolContract) => ({
|
||||
"~standard": {
|
||||
version: 1 as const,
|
||||
vendor: "rea",
|
||||
validate: (input: unknown) => ({ value: input }),
|
||||
jsonSchema: {
|
||||
input: () => advertisedInputJsonSchema(schema),
|
||||
output: () => advertisedInputJsonSchema(schema),
|
||||
input: () => advertisedInputJsonSchema(contract),
|
||||
output: () => advertisedInputJsonSchema(contract),
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -56,11 +56,14 @@ const advertisedOutputSchema = (schema: z.ZodObject) => {
|
||||
};
|
||||
|
||||
const advertisedInputJsonSchema = (
|
||||
schema: z.ZodObject,
|
||||
contract: ToolContract,
|
||||
): Readonly<Record<string, unknown>> =>
|
||||
cachedJsonSchema(ADVERTISED_INPUT_SCHEMAS, schema, () =>
|
||||
describeProperties(closeObjectSchemas(inputJsonSchema(schema))),
|
||||
);
|
||||
cachedJsonSchema(ADVERTISED_INPUT_SCHEMAS, contract.inputSchema, () => ({
|
||||
...describeProperties(
|
||||
closeObjectSchemas(inputJsonSchema(contract.inputSchema)),
|
||||
),
|
||||
examples: contract.examples.map(({ input }) => input),
|
||||
}));
|
||||
|
||||
const advertisedOutputJsonSchema = (
|
||||
schema: z.ZodObject,
|
||||
|
||||
Reference in New Issue
Block a user