11# frozen_string_literal: true
22
33require "mcp"
4- require_relative "tools/search_tool"
5- require_relative "tools/list_category"
6- require_relative "tools/get_details"
7- require_relative "tools/find_related"
8- require_relative "tools/parameter_search"
9- require_relative "tools/member_search"
10- require_relative "tools/list_topics"
11- require_relative "tools/get_topic"
124
135module CF
146 module MCP
157 class Server
168 attr_reader :server , :index
179
18- TOOLS = [
19- Tools ::SearchTool ,
20- Tools ::ListCategory ,
21- Tools ::GetDetails ,
22- Tools ::FindRelated ,
23- Tools ::ParameterSearch ,
24- Tools ::MemberSearch ,
25- Tools ::ListTopics ,
26- Tools ::GetTopic
27- ] . freeze
28-
2910 CORS_HEADERS = {
3011 "access-control-allow-origin" => "*" ,
3112 "access-control-allow-methods" => "GET, POST, DELETE, OPTIONS" ,
@@ -59,6 +40,7 @@ def self.build_rack_app(root: nil, download: false)
5940
6041 def initialize ( index )
6142 @index = index
43+
6244 configuration = ::MCP ::Configuration . new ( protocol_version : PROTOCOL_VERSION )
6345 @server = ::MCP ::Server . new (
6446 name : "cf-mcp" ,
@@ -70,7 +52,16 @@ def initialize(index)
7052 ::MCP ::Icon . new ( src : "#{ WEBSITE_URL } /favicon.svg" , mime_type : "image/svg+xml" , sizes : [ "any" ] ) ,
7153 ::MCP ::Icon . new ( src : "#{ WEBSITE_URL } /favicon-96x96.png" , mime_type : "image/png" , sizes : [ "96x96" ] )
7254 ] ,
73- tools : TOOLS ,
55+ tools : [
56+ Tools ::SearchTool ,
57+ Tools ::ListCategory ,
58+ Tools ::GetDetails ,
59+ Tools ::FindRelated ,
60+ Tools ::ParameterSearch ,
61+ Tools ::MemberSearch ,
62+ Tools ::ListTopics ,
63+ Tools ::GetTopic
64+ ] ,
7465 resources : build_topic_resources ( index )
7566 )
7667 @server . server_context = { index : index }
@@ -94,7 +85,7 @@ def rack_app
9485
9586 landing_page = build_landing_page
9687 index = @index
97- tools = TOOLS
88+ tools = @server . tools . values
9889 cors_headers = CORS_HEADERS
9990 public_dir = PUBLIC_DIR
10091
0 commit comments