Commit Graph

14 Commits

Author SHA1 Message Date
4bd5609e13 feat: add status watcher to MCP server (#18320)
This is meant to complement the existing task reporter since the LLM
does not call it reliably.

It also includes refactoring to use the common agent flags/env vars.
2025-06-13 12:53:43 -08:00
bedeb4710b fix: improve task reporting tool description (#18119)
In my (albeit subjective) testing, this dramatically improved the
reporting ability - both in frequency and accuracy.
2025-05-30 00:00:12 +00:00
b551a062d7 fix: correct environment variable name for MCP app status slug (#17948)
Fixed environment variable name for app status slug in Claude MCP configuration from `CODER_MCP_CLAUDE_APP_STATUS_SLUG` to `CODER_MCP_APP_STATUS_SLUG` to maintain consistency with other MCP environment variables.

This also caused the User level Claude.md to not contain instructions to report its progress, so it did not receive status reports.
2025-05-20 19:35:19 +02:00
29bce8d9e6 feat(cli): make MCP server work without user authentication (#17688)
Part of #17649

---

# Allow MCP server to run without authentication

This PR enhances the MCP server to operate without requiring authentication, making it more flexible for environments where authentication isn't available or necessary. Key changes:

- Replaced `InitClient` with `TryInitClient` to allow the MCP server to start without credentials
- Added graceful handling when URL or authentication is missing
- Made authentication status visible in server logs
- Added logic to skip user-dependent tools when no authenticated user is present
- Made the `coder_report_task` tool available with just an agent token (no user token required)
- Added comprehensive tests to verify operation without authentication

These changes allow the MCP server to function in more environments while still using authentication when available, improving flexibility for CI/CD and other automated environments.
2025-05-07 21:53:06 +02:00
2acf0adcf2 chore(codersdk/toolsdk): improve static analyzability of toolsdk.Tools (#17562)
* Refactors toolsdk.Tools to remove opaque `map[string]any` argument in
favour of typed args structs.
* Refactors toolsdk.Tools to remove opaque passing of dependencies via
`context.Context` in favour of a tool dependencies struct.
* Adds panic recovery and clean context middleware to all tools.
* Adds `GenericTool` implementation to allow keeping `toolsdk.All` with
uniform type signature while maintaining type information in handlers.
* Adds stricter checks to `patchWorkspaceAgentAppStatus` handler.
2025-04-29 16:05:23 +01:00
22b932a8e0 fix(cli): fix prompt issue in mcp configure claude-code (#17599)
* Updates default Coder prompt.
* Skips the directions to report tasks if the pre-requisites are not
available (agent token and app slug).
* Adds the capability to override the default Coder prompt via
`CODER_MCP_CLAUDE_CODER_PROMPT`.
2025-04-29 15:23:16 +01:00
2d2c9bda98 fix(cli): correct logic around CODER_MCP_APP_STATUS_SLUG (#17391)
Past me was not smart.
2025-04-14 16:24:02 +01:00
7b0422b49b fix(codersdk/toolsdk): fix tool schemata (#17365)
Fixes two issues with the MCP server:
- Ensures we have a non-null schema, as the following schema was making
claude-code unhappy:

 
```
        "inputSchema": { "type": "object", "properties": null },
```


- Skip adding the coder_report_task tool if an agent client is not
available. Otherwise the agent may try to report tasks and get confused.
2025-04-11 18:58:17 +01:00
1235550637 feat(codersdk): add toolsdk and replace existing mcp server tool impl (#17343)
- Refactors existing `mcp` package to use `kylecarbs/aisdk-go` and moves
to `codersdk/toolsdk` package.
- Updates existing MCP server implementation to use `codersdk/toolsdk`

Co-authored-by: Kyle Carberry <kyle@coder.com>
2025-04-11 10:24:45 +01:00
4aa45a5c43 fix(cli): modify exp mcp configure to also read claude API key from CLAUDE_API_KEY env (#17229)
Currently you have to set `CODER_MCP_CLAUDE_API_KEY`, which can be
obnoxious.
2025-04-03 09:45:17 +01:00
88bae05223 feat(cli): implement exp mcp configure claude-code command (#17195)
Updates `~/.claude.json` and `~/.claude/CLAUDE.md` with required
settings for agentic usage.
2025-04-01 20:06:42 +01:00
27d2343adf fix(cli): exp mcp: remove unnecessary cli flag (#17190) 2025-04-01 16:53:18 +01:00
1e11e823c9 fix(mcp): report task status correctly (#17187) 2025-04-01 15:02:08 +01:00
057cbd4d80 feat(cli): add coder exp mcp command (#17066)
Adds a `coder exp mcp` command which will start a local MCP server
listening on stdio with the following capabilities:
* Show logged in user (`coder whoami`)
* List workspaces (`coder list`)
* List templates (`coder templates list`)
* Start a workspace (`coder start`)
* Stop a workspace (`coder stop`)
* Fetch a single workspace (no direct CLI analogue)
* Execute a command inside a workspace (`coder exp rpty`)
* Report the status of a task (currently a no-op, pending task support)

This can be tested as follows:

```
# Start a local Coder server.
./scripts/develop.sh
# Start a workspace. Currently, creating workspaces is not supported.
./scripts/coder-dev.sh create -t docker --yes
# Add the MCP to your Claude config.
claude mcp add coder ./scripts/coder-dev.sh exp mcp
# Tell Claude to do something Coder-related. You may need to nudge it to use the tools.
claude 'start a docker workspace and tell me what version of python is installed'
```
2025-03-31 18:52:09 +01:00