As part of the epic to automate MCP server startup and reduce agent protocol (#7604), we should proactively fetch and cache the user's permission level for the repository when the github-workflow server starts. Currently, an agent would need to explicitly call the get_viewer_permission tool, which is an unnecessary extra step.
By fetching this information on startup, we simplify the agent's workflow and make the permission data readily available to all internal services.
Proposed Solution
Add a Cache Field: In ai/mcp/server/github-workflow/services/RepositoryService.mjs, add a new class field to the singleton, such as viewerPermission = null;, to hold the permission string.
Fetch on Startup: In ai/mcp/server/github-workflow/mcp-stdio.mjs, modify the main() startup function. After the initial health check, call the RepositoryService.getViewerPermission() method once and store its result in the new viewerPermission field on the RepositoryService singleton.
Refactor getViewerPermission Tool: Modify the getViewerPermission method in RepositoryService to be a simple, synchronous getter. Instead of making a GraphQL call, it should just return the value cached in the viewerPermission field. The actual GraphQL call will be moved to a new private method (e.g., #fetchViewerPermission) used only during startup.
Acceptance Criteria
- When the
github-workflow server starts, it makes one call to determine the viewer's permission level.
- The permission level is stored on the
RepositoryService singleton.
- The
get_viewer_permission tool reads from the cached value and does not make a new API call.
- Other services can import
RepositoryService and access the permission level directly (e.g., RepositoryService.viewerPermission).
As part of the epic to automate MCP server startup and reduce agent protocol (#7604), we should proactively fetch and cache the user's permission level for the repository when the
github-workflowserver starts. Currently, an agent would need to explicitly call theget_viewer_permissiontool, which is an unnecessary extra step.By fetching this information on startup, we simplify the agent's workflow and make the permission data readily available to all internal services.
Proposed Solution
Add a Cache Field: In
ai/mcp/server/github-workflow/services/RepositoryService.mjs, add a new class field to the singleton, such asviewerPermission = null;, to hold the permission string.Fetch on Startup: In
ai/mcp/server/github-workflow/mcp-stdio.mjs, modify themain()startup function. After the initial health check, call theRepositoryService.getViewerPermission()method once and store its result in the newviewerPermissionfield on theRepositoryServicesingleton.Refactor
getViewerPermissionTool: Modify thegetViewerPermissionmethod inRepositoryServiceto be a simple, synchronous getter. Instead of making a GraphQL call, it should just return the value cached in theviewerPermissionfield. The actual GraphQL call will be moved to a new private method (e.g.,#fetchViewerPermission) used only during startup.Acceptance Criteria
github-workflowserver starts, it makes one call to determine the viewer's permission level.RepositoryServicesingleton.get_viewer_permissiontool reads from the cached value and does not make a new API call.RepositoryServiceand access the permission level directly (e.g.,RepositoryService.viewerPermission).