Skip to content

Feature: Support for custom items#343

Merged
rafaeljusto merged 5 commits into
mainfrom
custom-items
May 28, 2026
Merged

Feature: Support for custom items#343
rafaeljusto merged 5 commits into
mainfrom
custom-items

Conversation

@CFDan

@CFDan CFDan commented May 28, 2026

Copy link
Copy Markdown
Contributor

Description

Builds on Teamwork/twapi-go-sdk#90 to support Custom Items in the MCP server

@CFDan CFDan requested a review from rafaeljusto May 28, 2026 16:23
@CFDan CFDan requested a review from a team as a code owner May 28, 2026 16:23
Comment thread internal/twprojects/custom_item_fields.go Outdated
SDK bump:
- Adopt typed list filters: CustomFieldOrderBy, CustomItemOrderBy,
  CustomItemRecordOrderBy, CustomItemSideload, TagItemType, UserType.
- Switch NullableInt64 helpers from projects.* to twapi.* (the types
  moved to the SDK root in v1.18.0).
- Drop the order_by knob on list_custom_item_fields — v1.18.0 removed
  CustomItemFieldListRequestFilters.OrderBy.
- Realign order_by enums in tool schemas with the SDK's canonical
  casing (lowercase for *OrderBy, uppercase for TagItemType).

Cache fixes:
- Scope the field-schema cache by {installationID, customItemID}.
  customItemID is only unique within an installation; the previous
  bare-int64 key let two tenants with the same id collide and read or
  write each other's field schema.
- Replace the mutex-backed map with a sync.Map plus an opportunistic
  sweep gated by a 5-minute CAS, so expired entries actually leave
  memory instead of accumulating forever.
- installationID comes from request.InfoFromContext; under STDIO it
  collapses to 0 (single-tenant process), which is the correct key.

Refactor:
- Move the cache into internal/twprojects/custom_item_fields_resolver.go
  with customItemField-prefixed names (customItemFieldCache,
  customItemFieldCacheKey, resolveCustomItemFields, etc.) to keep it
  out of custom_item_fields.go's tool definitions.
- Add tests covering tenant-key scoping, STDIO fallback, sweep
  eviction, and the sweep rate limit.
Cover create/update/delete/get/list across custom_items.go,
custom_item_fields.go, and custom_item_records.go using the existing
mcpServerMock pattern. Record create dispatches a field-list GET
before the record POST with different expected statuses, so add a
ProjectsMCPServerRoutedMock helper in testutil that returns responses
based on a substring match against the request path.
@rafaeljusto rafaeljusto changed the title Support for custom items Feature: Support for custom items May 28, 2026
@rafaeljusto rafaeljusto merged commit 4036f28 into main May 28, 2026
3 checks passed
@rafaeljusto rafaeljusto deleted the custom-items branch May 28, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants