Skip to content

Commit 6e0fdd7

Browse files
committed
add more tool
1 parent cd7a21c commit 6e0fdd7

9 files changed

+129
-295
lines changed

src/core/tools/schemas/__tests__/base-tool-schema.test.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/core/tools/schemas/__tests__/function-call-converter.test.ts

Lines changed: 0 additions & 202 deletions
This file was deleted.

src/core/tools/schemas/__tests__/tool-registry.test.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { ToolArgs } from "../../prompts/tools/types"
2+
import { BaseToolSchema } from "./base-tool-schema"
3+
4+
const baseAccessMcpResourceSchema: BaseToolSchema = {
5+
name: "access_mcp_resource",
6+
description:
7+
"Request to access a resource provided by a connected MCP server. Resources represent data sources that can be used as context, such as files, API responses, or system information.",
8+
parameters: [
9+
{
10+
name: "server_name",
11+
type: "string",
12+
description: "The name of the MCP server providing the resource",
13+
required: true,
14+
},
15+
{
16+
name: "uri",
17+
type: "string",
18+
description: "The URI identifying the specific resource to access",
19+
required: true,
20+
},
21+
],
22+
}
23+
24+
export const accessMcpResourceSchema: BaseToolSchema = {
25+
...baseAccessMcpResourceSchema,
26+
customDescription: (args: ToolArgs) => {
27+
if (!args.mcpHub) {
28+
return undefined
29+
}
30+
const schema = JSON.parse(JSON.stringify(baseAccessMcpResourceSchema))
31+
return schema as BaseToolSchema
32+
},
33+
}

src/core/tools/schemas/base-tool-schema.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface BaseToolSchema {
1818
name: string
1919
description: string
2020
parameters: ToolParameter[]
21-
customDescription?: (args: ToolArgs) => BaseToolSchema
21+
customDescription?: (args: ToolArgs) => BaseToolSchema | undefined
2222
}
2323

2424
/**
@@ -52,8 +52,7 @@ function toolParamToSchema(param: ToolParameter): any {
5252
/**
5353
* Converts a BaseToolSchema to OpenAI function call schema
5454
*/
55-
export function generateFunctionCallSchema(baseSchema: BaseToolSchema, args?: ToolArgs): any {
56-
const schema = baseSchema.customDescription ? baseSchema.customDescription(args || ({} as ToolArgs)) : baseSchema
55+
export function generateFunctionCallSchema(schema: BaseToolSchema) {
5756
const { name, description, parameters } = schema
5857
const properties: Record<string, any> = {}
5958
const required: string[] = []
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { ToolArgs } from "../../prompts/tools/types"
2+
import { BaseToolSchema } from "./base-tool-schema"
3+
4+
const baseCodebaseSearchSchema: BaseToolSchema = {
5+
name: "codebase_search",
6+
description:
7+
"Find files most relevant to the search query. This is a semantic search tool, so the query should ask for something semantically matching what is needed. If it makes sense to only search in a particular directory, please specify it in the path parameter. Unless there is a clear reason to use your own search query, please just reuse the user's exact query with their wording. Their exact wording/phrasing can often be helpful for the semantic search query. Keeping the same exact question format can also be helpful. IMPORTANT: Queries MUST be in English. Translate non-English queries before searching.",
8+
parameters: [
9+
{
10+
name: "query",
11+
type: "string",
12+
description:
13+
"The search query to find relevant code. You should reuse the user's exact query/most recent message with their wording unless there is a clear reason not to.",
14+
required: true,
15+
},
16+
{
17+
name: "path",
18+
type: "string",
19+
description:
20+
"The path to the directory to search in relative to the current working directory. This parameter should only be a directory path, file paths are not supported. Defaults to the current working directory.",
21+
required: false,
22+
},
23+
],
24+
}
25+
26+
export const codebaseSearchSchema: BaseToolSchema = {
27+
...baseCodebaseSearchSchema,
28+
}

0 commit comments

Comments
 (0)