Add twchat toolset for Teamwork Chat#347
Conversation
Wrap six Teamwork Chat API endpoints as MCP tools: get_current_user, list_conversations, get_conversation, list_messages, list_people (reads) and send_message (write, gated by read-only mode). The Chat API is served at /chat/v7/... on the same installation host as the Projects API and uses the same bearer token, so the tools ride the existing twapi.Engine via custom HTTPRequester types and stream the raw JSON response through twapi.ExecuteRaw. No new SDK or config required. Register the group in the stdio and http entry points and add a ChatMCPServerMock test helper reusing ProjectsEngineMock.
Add get_or_create_dm (GET /chat/v7/people/:id/conversation) to resolve or create the 1:1 pair conversation with a person, and send_dm, a convenience write tool that resolves that conversation and posts a message in one call. There is no server-side "send to person" endpoint, so send_dm composes the two calls client-side. Also expose filter[type] (rooms|pair) on list_conversations so agents can narrow to direct messages or group conversations.
|
There's also some tool filtering depending on what scope your token allows here: Lines 252 to 260 in dc4158f |
|
All non-blocking. Reviewed by Claude against some token optimisation work we've done recently 🤖 Token-count review (scoped to tool/param descriptions) — summary to go with the two inline notes above. Verdict: lean and on-convention — not a bloat problem. Measured with Two things worth addressing:
|
- Reuse helpers.SearchTermSchema/PageSchema/PageOffsetSchema and DateTimeFilterSchema in the twchat tools for consistency with the other toolsets; keep page_limit/page_size inline since they carry the API's max-10 / 1-200 ranges. - Add "chat" to scopes_supported in the OAuth protected-resource metadata. - Gate twchat tools behind the "chat" scope in the tool-list filter, mirroring the projects/desk/spaces handling.
|
Still have to test. Okay to chuck it onto staging to give it a go? |
Fire away. Changes should trigger a build once merged to the |
Summary
Adds a new
twchattoolset exposing basic Teamwork Chat support, alongside the existingtwprojects,twspaces, andtwdesktoolsets.The Chat API is served at
/chat/v7/...on the same installation host as the Projects API and authenticates with the same bearer token, so these tools ride the existingtwapi.Enginevia customHTTPRequestertypes and stream the raw JSON response throughtwapi.ExecuteRaw. No new SDK dependency or config is required.Tools
Six tools under one sub-toolset (
twchat-chat) — 5 read + 1 write (send_messageis gated automatically by read-only mode):twchat-get_current_userGET /chat/v7/metwchat-list_conversationsGET /chat/v7/conversationstwchat-get_conversationGET /chat/v7/conversations/:idtwchat-list_messagesGET /chat/v7/conversations/:id/messagestwchat-list_peopleGET /chat/v7/peopletwchat-send_messagePOST /chat/v7/conversations/:id/messagesImplementation
internal/twchat/:tools.go(registration +DefaultToolsetGroup),requests.go(theHTTPRequestertypes),chat.go(tool constructors + sharedexecutehelper).cmd/mcp-stdio/main.goandcmd/mcp-http/main.go.testutil.ChatMCPServerMock(reuses the existingProjectsEngineMock) plus one test per tool.twprojectsbudget/list pattern.Verification
gofmt -s,go build ./...,go vet ./..., andgo test ./...all pass; the new twchat tests are green.Out of scope (future)
Reactions, starring, conversation create/update/leave, attachments/file upload, and message edit/delete — easy follow-ups on the same pattern.