Class: Slack::MCPServer
- Inherits:
-
Object
- Object
- Slack::MCPServer
- Defined in:
- lib/utilities/slack/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 |
# File 'lib/utilities/slack/mcp.rb', line 10 def initialize # Defer SlackTool initialization until actually needed @slack_tool = nil @tools = { "test_connection" => { name: "test_connection", description: "Test the Slack API connection", inputSchema: { type: "object", properties: {}, required: [] } }, "list_channels" => { name: "list_channels", description: "List available Slack channels. When asked to list ALL channels, automatically retrieve all pages by calling this tool multiple times with the cursor parameter to get complete results.", inputSchema: { type: "object", properties: { limit: { type: "number", description: "Maximum number of channels to return (default: 100, max: 1000)" }, cursor: { type: "string", description: "Cursor for pagination. Use the next_cursor from previous response to get next page" }, exclude_archived: { type: "boolean", description: "Exclude archived channels from results (default: true)" } }, required: [] } }, "post_message" => { name: "post_message", description: "Post a message to a Slack channel", inputSchema: { type: "object", properties: { channel: { type: "string", description: "The Slack channel name (with or without #)" }, text: { type: "string", description: "The message text to post" }, username: { type: "string", description: "Optional custom username for the message" }, thread_ts: { type: "string", description: "Optional timestamp of parent message to reply to" } }, required: ["channel", "text"] } } } end |
Instance Method Details
#run ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/utilities/slack/mcp.rb', line 74 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("slack", "startup"), "#{Time.now}: Slack 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("slack", "error"), "#{Time.now}: #{e.message}\n#{e.backtrace.join("\n")}\n", mode: "a") end |