@@ -8,28 +8,19 @@ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
8
8
import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js' ;
9
9
import { CallToolRequestSchema , ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js' ;
10
10
11
- import { defaults } from '../const.js' ;
11
+ import inputSchema from '../../.actor/input_schema.json' assert { type : ' json ' } ;
12
12
import { handleModelContextProtocol } from '../search.js' ;
13
13
import { Input } from '../types.js' ;
14
14
15
- const TOOL_SEARCH = 'search' ;
15
+ const TOOL_SEARCH = inputSchema . title . toLowerCase ( ) . replace ( / / g , '-' ) ;
16
16
17
- const WebBrowserArgsSchema = {
18
- type : 'object' ,
19
- properties : {
20
- query : {
21
- type : 'string' ,
22
- description : 'Google Search keywords or a URL of a specific web page' ,
23
- } ,
24
- maxResults : {
25
- type : 'integer' ,
26
- description : 'The maximum number of top organic Google Search results whose web pages will be extracted (default: 1)' ,
27
- default : defaults . maxResults ,
28
- minimum : 1 , // Ensures the number is positive
29
- } ,
17
+ const TOOLS = [
18
+ {
19
+ name : TOOL_SEARCH ,
20
+ description : inputSchema . description ,
21
+ inputSchema,
30
22
} ,
31
- required : [ 'query' ] ,
32
- } ;
23
+ ] ;
33
24
34
25
/**
35
26
* Create an MCP server with a tool to call RAG Web Browser Actor
@@ -66,23 +57,15 @@ export class RagWebBrowserServer {
66
57
private setupToolHandlers ( ) : void {
67
58
this . server . setRequestHandler ( ListToolsRequestSchema , async ( ) => {
68
59
return {
69
- tools : [
70
- {
71
- name : TOOL_SEARCH ,
72
- description : 'Search phrase or a URL at Google and return crawled web pages as text or Markdown' ,
73
- inputSchema : WebBrowserArgsSchema ,
74
- } ,
75
- ] ,
60
+ tools : TOOLS ,
76
61
} ;
77
62
} ) ;
78
63
this . server . setRequestHandler ( CallToolRequestSchema , async ( request ) => {
79
64
const { name, arguments : args } = request . params ;
80
65
switch ( name ) {
81
66
case TOOL_SEARCH : {
82
67
const content = await handleModelContextProtocol ( args as unknown as Input ) ;
83
- return {
84
- content : [ { type : 'text' , text : JSON . stringify ( content ) } ] ,
85
- } ;
68
+ return { content : content . map ( ( message ) => ( { type : 'text' , text : JSON . stringify ( message ) } ) ) } ;
86
69
}
87
70
default : {
88
71
throw new Error ( `Unknown tool: ${ name } ` ) ;
0 commit comments