Skip to content

Commit 6129167

Browse files
Tighten MCP executeTool and SSE error typings
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent e794249 commit 6129167

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎src/agent/mcp/client.ts‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ interface ServerConnection {
1616
actions: AgentActionDefinition[];
1717
}
1818

19+
type MCPToolResult = Awaited<ReturnType<Client["callTool"]>>;
20+
1921
const MCPToolActionParams = z.object({
2022
params: z
2123
.union([z.string(), z.record(z.string(), z.unknown())])
@@ -93,8 +95,10 @@ class MCPClient {
9395
: undefined
9496
);
9597

96-
transport.onerror = (error: any) => {
97-
console.error(`SSE error: ${error.message}`);
98+
transport.onerror = (error: unknown) => {
99+
const message =
100+
error instanceof Error ? error.message : String(error);
101+
console.error(`SSE error: ${message}`);
98102
};
99103
} else {
100104
if (!serverConfig.command) {
@@ -206,9 +210,9 @@ class MCPClient {
206210
*/
207211
async executeTool(
208212
toolName: string,
209-
parameters: Record<string, any>,
213+
parameters: Record<string, unknown>,
210214
serverId?: string
211-
): Promise<any> {
215+
): Promise<MCPToolResult> {
212216
// If no server ID provided and only one server exists, use that one
213217
if (!serverId && this.servers.size === 1) {
214218
serverId = [...this.servers.keys()][0];

0 commit comments

Comments
 (0)