Skip to main content
Glama

send_message_to_session

Send a message to an active Devin session and optionally post it to a linked Slack thread or channel. Maintains context between Devin and Slack for streamlined communication and task management.

Instructions

Send a message to an existing Devin session and optionally to the associated Slack thread

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYesMessage to send to Devin
session_idYesThe ID of the Devin session
slack_channelNoOptional Slack channel ID to post to
slack_thread_tsNoOptional Slack thread timestamp to reply to

Implementation Reference

  • The handler case for 'send_message_to_session' that validates inputs, sends the message to the Devin API endpoint `/session/{normalized_session_id}/message`, optionally forwards to Slack, and returns success/error responses.
    case "send_message_to_session": { const session_id = String(request.params.arguments?.session_id); const message = String(request.params.arguments?.message); const slack_channel = request.params.arguments?.slack_channel as string | undefined; const slack_thread_ts = request.params.arguments?.slack_thread_ts as string | undefined; if (!session_id) { return { content: [{ type: "text", text: "Error: session_id is required" }], isError: true }; } if (!message) { return { content: [{ type: "text", text: "Error: message is required" }], isError: true }; } try { // Send message to Devin API // Devin APIへメッセージ送信 const response = await axios.post( `${BASE_URL}/session/${normalizeSessionId(session_id)}/message`, { message }, { headers: getHeaders() } ); // APIレスポンスの詳細なチェック // HTTP 200系のステータスが返ってきたら基本的に成功とみなす // 空のオブジェクトが返る場合も成功と判断する const isSuccess = response.status >= 200 && response.status < 300; let slackResponse = null; // Slackスレッド情報が提供されていれば、Slackにも送信 if (isSuccess && slack_channel && slack_thread_ts) { slackResponse = await sendSlackMessage(slack_channel, message, slack_thread_ts); } if (isSuccess) { return { content: [{ type: "text", text: JSON.stringify({ status: "Message sent successfully", success: true, response_data: response.data || {}, slack_response: slackResponse ? { channel: slack_channel, thread_ts: slack_thread_ts, message_ts: slackResponse.ts } : null }, null, 2) }] }; } else { // APIレスポンスが成功しなかった場合 return { content: [{ type: "text", text: JSON.stringify({ status: "Message sending failed", success: false, http_status: response.status, response_data: response.data || {} }, null, 2) }], isError: true }; } } catch (error) { if (axios.isAxiosError(error)) { return { content: [{ type: "text", text: `Error sending message: ${error.response?.status} - ${JSON.stringify(error.response?.data)}` }], isError: true }; } return { content: [{ type: "text", text: `Unexpected error: ${error}` }], isError: true }; } }
  • Input schema defining the parameters for the send_message_to_session tool.
    inputSchema: { type: "object", properties: { session_id: { type: "string", description: "The ID of the Devin session" }, message: { type: "string", description: "Message to send to Devin" }, slack_channel: { type: "string", description: "Optional Slack channel ID to post to" }, slack_thread_ts: { type: "string", description: "Optional Slack thread timestamp to reply to" } }, required: ["session_id", "message"] }
  • src/index.ts:189-214 (registration)
    Tool registration in the ListToolsRequestSchema handler, including name, description, and input schema.
    { name: "send_message_to_session", description: "Send a message to an existing Devin session and optionally to the associated Slack thread", inputSchema: { type: "object", properties: { session_id: { type: "string", description: "The ID of the Devin session" }, message: { type: "string", description: "Message to send to Devin" }, slack_channel: { type: "string", description: "Optional Slack channel ID to post to" }, slack_thread_ts: { type: "string", description: "Optional Slack thread timestamp to reply to" } }, required: ["session_id", "message"] } },
  • Helper function to resolve Slack channel name or ID to channel ID, used indirectly via sendSlackMessage.
    async function getChannelId(channelNameOrId: string): Promise<string> { // すでにIDの場合 (C12345 形式) if (/^[C][A-Z0-9]{8,}$/.test(channelNameOrId)) { return channelNameOrId; } try { // チャンネル名の場合、一覧を取得して検索 const result = await slackClient.conversations.list(); if (result.channels && Array.isArray(result.channels)) { // チャンネル名で検索 (#は省略可能) const normalizedName = channelNameOrId.startsWith('#') ? channelNameOrId.substring(1) : channelNameOrId; const channel = result.channels.find( (ch) => ch.name === normalizedName ); if (channel && channel.id) { return channel.id; } } // 見つからない場合はエラー throw new Error(`Channel not found: ${channelNameOrId}`); } catch (error) { console.error(`Error resolving channel name to ID: ${error}`); throw error; } }
  • Helper function to send a message to a Slack channel/thread, called from the handler when Slack parameters are provided.
    async function sendSlackMessage(channel: string, text: string, threadTs?: string) { try { // チャンネルIDを解決 const channelId = await getChannelId(channel); const messageOptions = { channel: channelId, text, thread_ts: threadTs, as_user: true }; const response = await slackClient.chat.postMessage(messageOptions); return response; } catch (error) { console.error('Error sending message to Slack:', error); throw error; } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/kazuph/mcp-devin'

If you have feedback or need assistance with the MCP directory API, please join our Discord server