Skip to content

feat(mcp): add list_places filter, tool annotations, prompts, and bug fixes#474

Closed
Ivan-Malinovski wants to merge 10 commits into
mauriceboe:pr/474-mcp-improvementsfrom
Ivan-Malinovski:main
Closed

feat(mcp): add list_places filter, tool annotations, prompts, and bug fixes#474
Ivan-Malinovski wants to merge 10 commits into
mauriceboe:pr/474-mcp-improvementsfrom
Ivan-Malinovski:main

Conversation

@Ivan-Malinovski
Copy link
Copy Markdown
Contributor

@Ivan-Malinovski Ivan-Malinovski commented Apr 6, 2026

Summary

This PR adds a new list_places tool with assignment filtering, adds tool annotations to all MCP tools, improves tool descriptions, and fixes several pre-existing bugs discovered during testing.

This PR was motivated by the need to bring TREK's MCP implementation in line with MCP best practices — specifically adding tool annotations so LLM clients can understand read/write semantics before making tool calls.

MCP Best Practices Compliance

Tool annotations

All 35+ tools now have proper readOnlyHint, destructiveHint, idempotentHint, and openWorldHint annotations:

  • Read-only tools (TOOL_ANNOTATIONS_READONLY): list_trips, list_places, get_trip_summary, list_categories, search_place, etc.
  • Write tools (TOOL_ANNOTATIONS_WRITE): update_trip, update_place, update_day, update_reservation, etc.
  • Delete tools (TOOL_ANNOTATIONS_DELETE): delete_trip, delete_place, delete_budget_item, etc. (destructiveHint: true)
  • Create tools (TOOL_ANNOTATIONS_NON_IDEMPOTENT): create_place, create_trip, create_reservation, etc. (create = non-idempotent)

Impact: LLM clients like Perplexity can now make safer, informed decisions about tool usage without guessing or trying to reason through side effects.

MCP Prompts

3 prompts registered for structured LLM workflows:

  • trip-summary — loads full trip context before planning
  • packing-list — formatted packing checklist grouped by category
  • budget-overview — formatted budget summary with category breakdown

Resources

All 16 resources now have explicit mimeType: 'application/json' declarations.

Capabilities

Server announces listChanged: true for resources, tools, and prompts — informing clients when the tool set changes.

New Feature

list_places tool with assignment filter

A new MCP tool for listing places filtered by whether they're scheduled on a day:

list_places(tripId, {
  assignment: 'all'       // default — all places
  assignment: 'unassigned' // orphan activities not yet on any day
  assignment: 'assigned'   // places that ARE on a day
})

End-user impact: LLMs can now discover orphan (unassigned) activities in a trip — "Which places haven't been scheduled yet?" — enabling better travel planning workflows without manual inspection.

Also available via the trek://trips/{tripId}/places resource with ?assignment=unassigned query param.

Tool Quality Improvements

Enum descriptions

All z.enum fields now have explicit .describe() annotations so LLMs see valid options without guessing:

  • assignment"all", "unassigned", "assigned"
  • create_reservation.type — 10 reservation types
  • update_reservation.type — same 10 types
  • update_reservation.status"pending", "confirmed", "cancelled"

Error handling

  • MCP transport requests wrapped in try/catch — crashes now log actual errors instead of silently failing
  • All broadcast() calls wrapped in safeBroadcast() to prevent WebSocket errors from crashing tool handlers

Bug Fixes

Bug Description Fix
Connection exhaustion After ~3 write calls, server stopped responding entirely Fixed safeBroadcast recursive bug; streaming requests no longer crash the MCP
update_place missing fields category_id, osm_id, price, currency, place_time, end_time, duration_minutes, transport_mode not in tool schema Added all fields to tool schema, handler, and service UPDATE
create_collab_note ignores pinned pinned: true silently ignored Added pinned to createNote service INSERT and tool schema
osm_id silently ignored on update Service UPDATE didn't include osm_id Added osm_id to UPDATE statement and tool schema

Pre-existing Bugs Confirmed Working

  • create_place, update_place, list_places, get_trip_summary, list_trips, list_categories, search_place, assign_place_to_day, delete_place — all verified working
  • create_budget_item, create_packing_item, create_reservation — working (were failing before safeBroadcast fix)

Test Results

  • 513 unit tests: all pass ✅
  • Perplexity MCP integration: 50+ consecutive tool calls with no crashes ✅
  • Manual curl testing: all filter modes work correctly ✅

Commits (10 total)

Commit Description
9510fba feat: add list_places assignment filter for orphan activities
f5777ff fix: document assignment enum values in list_places description
d15b837 fix: add describe() to remaining z.enum fields
57c0108 fix: add error handling and logging to prevent silent crashes
e7206dc fix: wrap broadcast calls in try-catch to prevent WebSocket errors crashing tools
a5c7a49 fix: revert allowedOrigins to avoid SDK compatibility issues
52e2f7f fix: safeBroadcast now calls broadcast correctly (was recursive call bug)
7d9455b fix: add missing fields to update_place and create_collab_note pinned support
910159f fix: add osm_id to update_place

Disclaimer: Entirely vibe coded with MiniMax M2.7.

@Ivan-Malinovski Ivan-Malinovski changed the title feat(mcp): add list_places tool with assignment filter for orphan activities feat(mcp): add list_places filter, tool annotations, prompts, and bug fixes Apr 6, 2026
@jubnl jubnl changed the base branch from main to dev April 6, 2026 15:43
@mauriceboe mauriceboe added the approved on discord Discussed and greenlit on discord label Apr 7, 2026
@mauriceboe
Copy link
Copy Markdown
Owner

Manual approved today

@jubnl jubnl changed the base branch from dev to pr/474-mcp-improvements April 9, 2026 10:59
@jubnl
Copy link
Copy Markdown
Collaborator

jubnl commented Apr 9, 2026

I had some minor improvements to do, closing this pr in favor for #535

@jubnl jubnl closed this Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved on discord Discussed and greenlit on discord

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants