Overview
Returns a function to invoke other MCP tools registered on the server. Useful for multi-step workflows where one app needs to trigger another tool.
Import
import { useCallServerTool } from 'sunpeak';
Signature
function useCallServerTool(): (params: CallServerToolParams) => Promise<CallServerToolResult | undefined>
Name of the MCP tool to call.
Arguments to pass to the tool.
Returns
callTool
(params: CallServerToolParams) => Promise<CallServerToolResult | undefined>
Function to call an MCP server tool.
content
Array<{ type: string; text?: string }>
Tool response content.
Whether the tool call resulted in an error.
Usage
import { useCallServerTool } from 'sunpeak';
function ReviewResource() {
const callTool = useCallServerTool();
const handleApply = async () => {
const result = await callTool({
name: 'apply_changes',
arguments: { changesetId: 'cs_789' },
});
console.log('Tool result:', result);
};
return <button onClick={handleApply}>Apply Changes</button>;
}