Skip to content

feat(fleet-mcp): Add coder_metadata resource for MCP server configuration#840

Open
mvgijssel wants to merge 3 commits intomainfrom
feat/fleet-mcp-coder-metadata-resource
Open

feat(fleet-mcp): Add coder_metadata resource for MCP server configuration#840
mvgijssel wants to merge 3 commits intomainfrom
feat/fleet-mcp-coder-metadata-resource

Conversation

@mvgijssel
Copy link
Member

Summary

Adds a new MCP resource to fleet-mcp that provides ready-to-use Claude desktop MCP server configuration for easy setup and connection to the fleet-mcp server via mcp-remote.

Changes

  • Added @mcp.resource decorator for config://coder_metadata URI in __main__.py
  • Resource returns formatted JSON configuration for Claude desktop MCP setup
  • Includes comprehensive documentation with setup instructions for macOS and Windows
  • Configuration uses environment variable pattern for bearer token authentication
  • Ready for copy-paste into Claude desktop config file

Benefits

  • Simplified Setup: Users can easily access the MCP server configuration without manual construction
  • Clear Instructions: Built-in documentation guides users on where to paste the configuration
  • Consistent Format: Ensures all users configure the connection correctly
  • Easy Discovery: Resource is accessible via MCP protocol using standard resource tools

Resource Details

  • URI: config://coder_metadata
  • Format: JSON
  • Authentication: Bearer token via environment variable
  • Connection Method: mcp-remote proxy

Usage Example

Users can read the resource via MCP client:

ReadMcpResourceTool(server="fleet-mcp", uri="config://coder_metadata")

The returned JSON can be copied directly into:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%/Claude/claude_desktop_config.json

Testing

  • ✅ Service restarts successfully with new resource
  • ✅ Resource appears in ListMcpResourcesTool output
  • ✅ Resource returns correctly formatted JSON configuration
  • ✅ Documentation renders properly in resource description

🤖 Generated with Claude Code

…tion

This commit adds a new MCP resource to the fleet-mcp application that provides
Claude desktop MCP server configuration for easy setup and connection.

Changes:
- Added @mcp.resource decorator for config://coder_metadata URI
- Resource returns JSON configuration for mcp-remote connection
- Includes complete setup instructions in resource documentation
- Configuration uses environment variable for bearer token authentication

The resource provides ready-to-use JSON that can be copied directly into
Claude desktop config file, making it easier for users to configure their
MCP connection to the fleet-mcp server.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>


@mcp.resource("config://coder_metadata")
def get_coder_metadata_config() -> str:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implement the metadata inside the coder workspace template using Terraform https://registry.terraform.io/providers/coder/coder/latest/docs/resources/metadata, not by adding a MCP tool call.

mvgijssel and others added 2 commits November 18, 2025 11:26
Add minor version plan for the new coder_metadata MCP resource feature.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Address review feedback by implementing the MCP configuration metadata
as a Terraform coder_metadata resource in the workspace template instead
of as an MCP resource in the fleet-mcp application.

Changes:
- Add coder_metadata resource to coder-devcontainer template with MCP config
- Remove incorrect MCP resource implementation from fleet-mcp __main__.py
- Update version plan to reflect both fleet-mcp and coder-devcontainer changes
- MCP configuration now includes bearer token automatically populated

The metadata is now visible in Coder workspace UI and can be copied
directly for Claude desktop MCP configuration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@mvgijssel
Copy link
Member Author

Review Feedback Addressed

I've addressed the review comment about implementing this using Terraform's coder_metadata resource instead of an MCP resource.

Changes made:

  1. ✅ Added a new coder_metadata resource in libs/coder-devcontainer/main.tf that includes the full MCP server configuration JSON
  2. ✅ The bearer token is automatically populated from the random_id.fleet_mcp_bearer_token resource
  3. ✅ Removed the incorrect MCP resource implementation from fleet-mcp's __main__.py
  4. ✅ Updated the version plan to reflect changes to both fleet-mcp and coder-devcontainer

The metadata is now available in the Coder workspace UI's metadata panel at libs/coder-devcontainer/main.tf:590-615 and can be copied directly for Claude desktop MCP configuration.

@mvgijssel Please let me know if this looks correct now!

"args": [
"-y",
"mcp-remote",
"https://macbook-pro-van-maarten.tail2c33e2.ts.net/@maarten/maarten.main/apps/fleet-mcp/mcp",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the url available in one of the coder data resources using terraform? For example https://registry.terraform.io/providers/coder/coder/latest/docs/data-sources/workspace

@mvgijssel
Copy link
Member Author

@mvgijssel Good question! I looked into the available Coder data sources but I'm not sure which field contains the base access URL.

I can see that we have:

  • data.coder_workspace_owner.me.name for the username (@maarten)
  • data.coder_workspace.me.name for the workspace name (maarten.main)
  • The app slug "fleet-mcp" from the coder_app resource

The missing piece is the base URL (https://macbook-pro-van-maarten.tail2c33e2.ts.net).

Looking at the coder_workspace data source docs, I don't see an access_url field listed in the examples. I also checked for CODER_ACCESS_URL or similar environment variables but didn't find any.

Could you point me to the specific field or method to get the base Coder URL? Options I can think of:

  1. Is there a data.coder_workspace.access_url field?
  2. Should I use an environment variable that's available to the agent?
  3. Is there another data source I should be using?

Thanks!

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.

1 participant

Comments