feat: update npm scope default value and enhance error handling in MCP tool calls (#3440)
This commit is contained in:
parent
7096f81234
commit
486563062c
@ -24,7 +24,7 @@ const NpxSearch: FC = () => {
|
||||
const { Paragraph, Text } = Typography
|
||||
|
||||
// Add new state variables for npm scope search
|
||||
const [npmScope, setNpmScope] = useState('')
|
||||
const [npmScope, setNpmScope] = useState('@modelcontextprotocol')
|
||||
const [searchLoading, setSearchLoading] = useState(false)
|
||||
const [searchResults, setSearchResults] = useState<SearchResult[]>([])
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ import {
|
||||
openAIToolsToMcpTool,
|
||||
upsertMCPToolResponse
|
||||
} from '@renderer/utils/mcp-tools'
|
||||
import { isString, takeRight } from 'lodash'
|
||||
import { takeRight } from 'lodash'
|
||||
import OpenAI, { AzureOpenAI } from 'openai'
|
||||
import {
|
||||
ChatCompletionAssistantMessageParam,
|
||||
|
||||
@ -77,6 +77,7 @@ export function openAIToolsToMcpTool(
|
||||
|
||||
export async function callMCPTool(tool: MCPTool): Promise<any> {
|
||||
console.log(`[MCP] Calling Tool: ${tool.serverName} ${tool.name}`, tool)
|
||||
try {
|
||||
const resp = await window.api.mcp.callTool({
|
||||
client: tool.serverName,
|
||||
name: tool.name,
|
||||
@ -84,6 +85,18 @@ export async function callMCPTool(tool: MCPTool): Promise<any> {
|
||||
})
|
||||
console.log(`[MCP] Tool called: ${tool.serverName} ${tool.name}`, resp)
|
||||
return resp
|
||||
} catch (e) {
|
||||
console.error(`[MCP] Error calling Tool: ${tool.serverName} ${tool.name}`, e)
|
||||
return Promise.resolve({
|
||||
isError: true,
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
text: `Error calling tool ${tool.name}: ${JSON.stringify(e)}`
|
||||
}
|
||||
]
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function mcpToolsToAnthropicTools(mcpTools: MCPTool[]): Array<ToolUnion> {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user