Skip to content

feat(docs): Create a tool to safely replace bullet point text #16

@krisrowe

Description

@krisrowe

Summary

Enhance the Google Chat integration by implementing a persistent caching layer for People API data (e.g., user display names). Currently, author names are taken directly from the Chat message payload, which can be inconsistent or missing. A dedicated caching mechanism would improve performance and data consistency.

Current State

  • The list_chat_messages MCP tool extracts the author's displayName directly from the message object on each API call (e.g., message.get("author", {}).get("displayName")).
  • There is no caching for People data.
  • The existing cache in gwsa/sdk/cache.py is an in-memory cache, meaning it does not persist across separate CLI command invocations.

Desired State

  • User display names should be resolved from the People API and cached to reduce redundant API calls and provide consistent user information.
  • The cache should persist across separate CLI and MCP tool invocations. This means it needs to be file-based, not just in-memory.

Proposed Implementation Plan

  1. Enhance the Caching SDK (gwsa/sdk/cache.py):

    • Modify the ExpiringCache to support a file-based backend (e.g., using shelve or a simple JSON file).
    • The cache should serialize and deserialize its content to/from a file in ~/.config/gworkspace-access/cache/.
    • This will allow the cache to be shared between different processes and invocations.
  2. Create a People SDK Module (gwsa/sdk/people.py):

    • Create a new SDK module for interacting with the People API.
    • Implement a function get_user_display_name(user_id: str) that takes a user resource name (e.g., users/123456789).
    • This function should first check the persistent cache for the user's display name.
    • If the name is not in the cache (a cache miss), it should call the people.get method of the People API, store the result in the cache, and then return the name.
  3. Integrate Caching into Chat Tools (gwsa/mcp/server.py):

    • Modify the list_chat_messages tool.
    • For each message, extract the author's user resource name (from message.get("author", {}).get("name")).
    • Call the new gwsa.sdk.people.get_user_display_name() function to get the author's name (which will be served from the cache if available).
    • Use this resolved name in the tool's output.
  4. Add People API Scope:

    • The https://www.googleapis.com/auth/userinfo.profile scope (or a more specific People API scope) will need to be added to the default scopes to allow the People API calls.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions