Feature request / proposal: HTTP API for claude code
Hi, I'd like to request / propose an HTTP api to use claude code from other clients.
Some context - we're working on a mobile client for claude code for the SPC x Anthropic Hackathon and we found that the CLI api using -p is very limiting in exposing claude code's functionality through our custom python server. Specifically it doesn't allow us to have message history without manually passing previous requests as part of the prompt (see #775). We also didn't want to parse the interactive shell since that could break easily as claude code updates.
For our mobile app, we found that we needed a few APIs to be able to use claude code effectively, but these APIs would be very similar if other clients wanted to use Claude Code's functionality, specifically:
- auth - allow a user to authenticate to the http api
- prompt - allow a user to send a prompt that will run against a specific project directory. This could offer a streaming and non-streaming option.
- directories - allow a user to list out a directory tree to be able to browse to a specific project & choose that to chat with
An extension of prompt would also allow us to also pass the previous message history in the "stream-json" output format like in #775.
These would just be some preliminary APIs that other clients could also utilize to integrate claude code into other clients - would want to have an open discussion on what a proper http api could look like for other use cases too.
Note that there is another option here where claude code could be exposed as an MCP server itself, but unclear how that would look right now. Feel free to close out if this doesn't make sense as part of the claude-code project.
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗