Skip to content

Commit

Permalink
chore: update pnpm lockfile for modelcontextprotocoltools dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
arafatkatze committed Jan 11, 2025
1 parent 6faf372 commit b2a784a
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions provider/modelcontextprotocoltools/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { basename } from 'node:path'
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js'
import {
CallToolResultSchema,

} from '@modelcontextprotocol/sdk/types.js'
import { CallToolResultSchema } from '@modelcontextprotocol/sdk/types.js'
import type {
Item,
ItemsParams,
Expand Down Expand Up @@ -94,12 +91,12 @@ class MCPToolsProxy implements Provider {
for (const tool of tools) {
// Store the schema in the Map using tool name as key
this.toolSchemas.set(tool.name, JSON.stringify(tool.inputSchema))

const r = {
uri: tool.uri,
title: tool.name,
description: tool.description,
data: (tool.inputSchema),
data: tool.inputSchema,
} as Mention
mentions.push(r)
}
Expand Down Expand Up @@ -147,7 +144,9 @@ class MCPToolsProxy implements Provider {
const isValid = this.ajv.validate(schema, toolInput)
if (!isValid) {
console.error('Invalid tool input:', this.ajv.errors)
throw new Error(`Invalid input for tool ${toolName}: ${JSON.stringify(this.ajv.errors)}`)
throw new Error(
`Invalid input for tool ${toolName}: ${JSON.stringify(this.ajv.errors)}`,
)
}
}
}
Expand All @@ -156,14 +155,14 @@ class MCPToolsProxy implements Provider {
const response = await mcpClient.request(
{
method: 'tools/call' as const,
params: {
params: {
name: toolName,
arguments: toolInput
arguments: toolInput,
},
},
CallToolResultSchema,
)

const contents = response.content
const items: Item[] = []
for (const content of contents) {
Expand All @@ -190,6 +189,5 @@ class MCPToolsProxy implements Provider {
}
}


const proxy = new MCPToolsProxy()
export default proxy

0 comments on commit b2a784a

Please sign in to comment.