mirror of
https://github.com/aljazceru/opencode.git
synced 2026-01-22 09:14:57 +01:00
chore: rm debug logs
This commit is contained in:
@@ -223,11 +223,10 @@ export namespace MCP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const result = await withTimeout(mcpClient.tools(), mcp.timeout ?? 5000).catch((err) => {
|
const result = await withTimeout(mcpClient.tools(), mcp.timeout ?? 5000).catch((err) => {
|
||||||
log.error("create() failed to get tools from client", { key, error: err })
|
log.error("failed to get tools from client", { key, error: err })
|
||||||
return undefined
|
return undefined
|
||||||
})
|
})
|
||||||
if (!result) {
|
if (!result) {
|
||||||
log.info("create() tools() returned nothing, closing client", { key })
|
|
||||||
await mcpClient.close().catch((error) => {
|
await mcpClient.close().catch((error) => {
|
||||||
log.error("Failed to close MCP client", {
|
log.error("Failed to close MCP client", {
|
||||||
error,
|
error,
|
||||||
@@ -258,18 +257,14 @@ export namespace MCP {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function clients() {
|
export async function clients() {
|
||||||
const s = await state()
|
return state().then((state) => state.clients)
|
||||||
log.info("clients() called", { clientCount: Object.keys(s.clients).length })
|
|
||||||
return s.clients
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function tools() {
|
export async function tools() {
|
||||||
const result: Record<string, Tool> = {}
|
const result: Record<string, Tool> = {}
|
||||||
const s = await state()
|
const s = await state()
|
||||||
log.info("tools() called", { clientCount: Object.keys(s.clients).length })
|
|
||||||
const clientsSnapshot = await clients()
|
const clientsSnapshot = await clients()
|
||||||
for (const [clientName, client] of Object.entries(clientsSnapshot)) {
|
for (const [clientName, client] of Object.entries(clientsSnapshot)) {
|
||||||
log.info("tools() fetching tools for client", { clientName })
|
|
||||||
const tools = await client.tools().catch((e) => {
|
const tools = await client.tools().catch((e) => {
|
||||||
log.error("failed to get tools", { clientName, error: e.message })
|
log.error("failed to get tools", { clientName, error: e.message })
|
||||||
const failedStatus = {
|
const failedStatus = {
|
||||||
@@ -280,17 +275,14 @@ export namespace MCP {
|
|||||||
delete s.clients[clientName]
|
delete s.clients[clientName]
|
||||||
})
|
})
|
||||||
if (!tools) {
|
if (!tools) {
|
||||||
log.info("tools() no tools returned for client", { clientName })
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
log.info("tools() got tools for client", { clientName, toolCount: Object.keys(tools).length })
|
|
||||||
for (const [toolName, tool] of Object.entries(tools)) {
|
for (const [toolName, tool] of Object.entries(tools)) {
|
||||||
const sanitizedClientName = clientName.replace(/[^a-zA-Z0-9_-]/g, "_")
|
const sanitizedClientName = clientName.replace(/[^a-zA-Z0-9_-]/g, "_")
|
||||||
const sanitizedToolName = toolName.replace(/[^a-zA-Z0-9_-]/g, "_")
|
const sanitizedToolName = toolName.replace(/[^a-zA-Z0-9_-]/g, "_")
|
||||||
result[sanitizedClientName + "_" + sanitizedToolName] = tool
|
result[sanitizedClientName + "_" + sanitizedToolName] = tool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.info("tools() final result", { toolCount: Object.keys(result).length })
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user