📝 docs: clarify hub exec return

This commit is contained in:
Vaayne 2025-12-30 17:50:48 +08:00
parent 1554f082ec
commit 0022087cc0
2 changed files with 3 additions and 3 deletions

View File

@ -81,7 +81,7 @@ export class HubServer {
code: {
type: 'string',
description:
'JavaScript code to execute. Can use async/await. Available helpers: parallel(...promises), settle(...promises). The last expression is returned.'
'JavaScript code to execute. Runs inside an async function. Can use async/await. Available helpers: parallel(...promises), settle(...promises). Use return (or a final expression) to produce output; otherwise result is undefined.'
}
},
required: ['code']

View File

@ -479,7 +479,7 @@ You have access to MCP tools via the hub server.
1. Call \`search\` with relevant keywords to discover tools
2. Review the returned function signatures and their parameters
3. Call \`exec\` with JavaScript code using those functions (you can chain multiple MCP tools in one \`exec\`)
4. The last expression in your code becomes the result (avoid top-level \`return\`)
4. The last expression (or an explicit \`return\`) becomes the result. If you don't return anything, the result is \`undefined\`.
### Example Usage
@ -527,7 +527,7 @@ exec({
- Handle errors gracefully with try/catch when needed
- Use \`parallel()\` for independent operations to improve performance
- Prefer a single \`exec\` for multi-step flows to reduce round-trips
- Avoid top-level \`return\`; use the last expression or wrap in an async IIFE
- Return a value (or end with a final expression) so \`exec\` produces output
- Use the exact tool names/signatures returned by \`search\`
`