feat: add create-conversation tool and message attachments#198
Open
jgalea wants to merge 2 commits into
Open
Conversation
Add a create-conversation tool that starts or reuses a direct/group conversation and posts an initial message. Add local-file attachment support, wired into create-conversation and reply (both conversation messages and thread comments), via a new uploadAttachments helper that POSTs to the Twist attachments/upload endpoint. Thread creation does not support attachments because the SDK's createThread args have no attachments field.
Collaborator
It does now. That said, I'm not sure whether we will accept the attachment tool right now. We have a similar PR on the Todoist MCP and we have been unable to come to a concensus on this. I will add this to the Twist CLI though. The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a
create-conversationtool and local-file attachment support for messages.create-conversationstarts a direct or group conversation and posts an initial message. It callsgetOrCreateConversation, so it reuses an existing conversation when the same set of users already has one rather than creating a duplicate. Params:workspaceId,recipients(user IDs, min 1),content, and optionalattachments.Attachments are local filesystem paths (the MCP server runs locally, so reading paths with
node:fsis the right interface). A newuploadAttachmentshelper insrc/utils/attachments.tsreads each file, uploads it to Twist, and returns the attachment objects to pass into the SDK call. The Twist SDK has no upload method, so the helper does a raw multipart POST toPOST /api/v3/attachments/uploadwith fieldsattachment_id(a generated UUID) andfile_name(the binary), matching the documented curl example at https://developer.twist.com/v3/#add-attachment. It reuses the client's auth token and base URL, validates file existence with a clear error, and surfaces non-OK upload responses.Attachments are wired into
create-conversationandreply(both conversation messages viacreateMessageand thread comments viacreateComment). The structured output and text summary include the attachment count and names when files are attached.create-threaddoes not get attachment support: the SDK'sCreateThreadArgshas noattachmentsfield, so rather than adding a parameter that silently does nothing, it is left out and noted here. If the SDK adds it later, the same helper can be wired in.Tests cover the new tool, the upload helper (mocked
fetch, real temp files, error paths), and the attachment paths inreply. type-check, the full jest suite, build, and oxlint/oxfmt all pass.