Class: Notion::MCPServer
- Inherits:
-
Object
- Object
- Notion::MCPServer
- Defined in:
- lib/utilities/notion/mcp.rb
Instance Method Summary collapse
-
#initialize ⇒ MCPServer
constructor
A new instance of MCPServer.
- #run ⇒ Object
Constructor Details
#initialize ⇒ MCPServer
Returns a new instance of MCPServer.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/utilities/notion/mcp.rb', line 10 def initialize # Defer Service initialization until actually needed @notion_tool = nil @tools = { "test_connection" => { name: "test_connection", description: "Test the Notion API connection", inputSchema: { type: "object", properties: {}, required: [] } }, "search_pages" => { name: "search_pages", description: "Search for pages in Notion workspace", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query to find pages (optional, searches all pages if empty)" }, page_size: { type: "number", description: "Maximum number of results to return (default: 10, max: 100)" } }, required: [] } }, "search_databases" => { name: "search_databases", description: "Search for databases in Notion workspace", inputSchema: { type: "object", properties: { query: { type: "string", description: "Search query to find databases (optional, searches all databases if empty)" }, page_size: { type: "number", description: "Maximum number of results to return (default: 10, max: 100)" } }, required: [] } }, "get_page" => { name: "get_page", description: "Get details of a specific Notion page", inputSchema: { type: "object", properties: { page_id: { type: "string", description: "The ID of the Notion page to retrieve" } }, required: ["page_id"] } }, "get_page_content" => { name: "get_page_content", description: "Get the text content of a Notion page", inputSchema: { type: "object", properties: { page_id: { type: "string", description: "The ID of the Notion page to get content from" } }, required: ["page_id"] } }, "query_database" => { name: "query_database", description: "Query entries in a Notion database", inputSchema: { type: "object", properties: { database_id: { type: "string", description: "The ID of the Notion database to query" }, page_size: { type: "number", description: "Maximum number of results to return (default: 100, max: 100)" }, start_cursor: { type: "string", description: "Cursor for pagination. Use the next_cursor from previous response to get next page" } }, required: ["database_id"] } }, "list_users" => { name: "list_users", description: "List all users in the Notion workspace", inputSchema: { type: "object", properties: { page_size: { type: "number", description: "Maximum number of results to return (default: 100, max: 100)" }, start_cursor: { type: "string", description: "Cursor for pagination. Use the next_cursor from previous response to get next page" } }, required: [] } }, "get_user" => { name: "get_user", description: "Get details of a specific Notion user", inputSchema: { type: "object", properties: { user_id: { type: "string", description: "The ID of the Notion user to retrieve" } }, required: ["user_id"] } }, "get_bot_user" => { name: "get_bot_user", description: "Get information about the integration bot user", inputSchema: { type: "object", properties: {}, required: [] } } } end |
Instance Method Details
#run ⇒ Object
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/utilities/notion/mcp.rb', line 153 def run # Disable stdout buffering for immediate response $stdout.sync = true # Log startup to file instead of stdout to avoid protocol interference Mcpeasy::Config.ensure_config_dirs File.write(Mcpeasy::Config.log_file_path("notion", "startup"), "#{Time.now}: Notion MCP Server starting on stdio\n", mode: "a") while (line = $stdin.gets) handle_request(line.strip) end rescue Interrupt # Silent shutdown rescue => e # Log to a file instead of stderr to avoid protocol interference File.write(Mcpeasy::Config.log_file_path("notion", "error"), "#{Time.now}: #{e.}\n#{e.backtrace.join("\n")}\n", mode: "a") end |