Skip to content

feat: add support for claude code as an MCP client#122

Merged
joshsny merged 3 commits intomainfrom
claude-code-mcp
Aug 19, 2025
Merged

feat: add support for claude code as an MCP client#122
joshsny merged 3 commits intomainfrom
claude-code-mcp

Conversation

@joshsny
Copy link
Copy Markdown
Collaborator

@joshsny joshsny commented Aug 19, 2025

Add Claude Code as an MCP client for the mcp add / remove commands.

Tested it locally. It is requiring the /sse endpoint to get working for me.

@joshsny joshsny requested review from Copilot and jonathanlab and removed request for Copilot August 19, 2025 13:43
Copy link
Copy Markdown
Collaborator

@jonathanlab jonathanlab left a comment

Choose a reason for hiding this comment

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

Very nice, works on my end as well!

Copilot AI review requested due to automatic review settings August 19, 2025 14:00
@joshsny joshsny enabled auto-merge (squash) August 19, 2025 14:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for Claude Code as an MCP (Model Context Protocol) client, expanding the list of supported clients beyond the existing Cursor and Claude clients. The changes enable users to add and remove MCP servers through Claude Code using its CLI interface.

  • Implements a new ClaudeCodeMCPClient class that integrates with Claude Code's MCP commands
  • Updates the supported clients list to include Claude Code
  • Changes the default server type from 'streamable-http' to 'sse' for all clients

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/steps/add-mcp-server-to-clients/index.ts Adds Claude Code client to the list of supported MCP clients
src/steps/add-mcp-server-to-clients/clients/claude-code.ts Implements the Claude Code MCP client with CLI integration
src/steps/add-mcp-server-to-clients/MCPClient.ts Changes default server type from 'streamable-http' to 'sse'

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

stdio: 'pipe',
});

if (output.toString().includes('posthog')) {
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

Hard-coding 'posthog' as the server name makes this check specific to one server type. Consider making this configurable or using a more generic approach to detect installed servers.

Suggested change
if (output.toString().includes('posthog')) {
if (output.toString().includes(this.serverName)) {

Copilot uses AI. Check for mistakes.
}

getConfigPath(): Promise<string> {
throw new Error('Not implemented');
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

The getConfigPath method throws 'Not implemented' but this method is part of the MCPClient interface. Either implement this method or mark it as optional in the interface if it's not needed for Claude Code.

Suggested change
throw new Error('Not implemented');
// Assuming Claude Code stores config at ~/.claude/config.json
const configPath = `${process.env.HOME || process.env.USERPROFILE}/.claude/config.json`;
return Promise.resolve(configPath);

Copilot uses AI. Check for mistakes.
addServer(apiKey: string): Promise<{ success: boolean }> {
const config = getDefaultServerConfig(apiKey, 'sse');

const command = `claude mcp add-json posthog -s user '${JSON.stringify(
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

Hard-coding 'posthog' as the server name in the command makes this client specific to PostHog servers. Consider parameterizing the server name to make this more generic.

Suggested change
const command = `claude mcp add-json posthog -s user '${JSON.stringify(
const command = `claude mcp add-json ${this.serverName} -s user '${JSON.stringify(

Copilot uses AI. Check for mistakes.
}

removeServer(): Promise<{ success: boolean }> {
const command = `claude mcp remove --scope user posthog`;
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

Hard-coding 'posthog' as the server name in the remove command creates the same maintainability issue as in addServer. Consider making the server name configurable.

Suggested change
const command = `claude mcp remove --scope user posthog`;
const command = `claude mcp remove --scope user ${this.serverName}`;

Copilot uses AI. Check for mistakes.
)}'`;

execSync(command);

Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

Using execSync with a command that includes JSON.stringify(config) could be vulnerable to command injection if the config contains malicious content. Consider using safer command execution methods or proper escaping.

Suggested change
// Use argument array to avoid command injection
execSync(
'claude',
[
'mcp',
'add-json',
'posthog',
'-s',
'user',
JSON.stringify(config),
],
{ stdio: 'ignore', shell: false }
);

Copilot uses AI. Check for mistakes.

async addServer(apiKey: string): Promise<{ success: boolean }> {
return this._addServerType(apiKey, 'streamable-http');
return this._addServerType(apiKey, 'sse');
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

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

Changing the default server type from 'streamable-http' to 'sse' is a breaking change that affects all existing MCP clients. This should be documented and may require version migration logic.

Copilot uses AI. Check for mistakes.
@joshsny joshsny disabled auto-merge August 19, 2025 14:39
@joshsny joshsny merged commit 0419a7d into main Aug 19, 2025
10 checks passed
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.

3 participants