Skip to content

Conversation

@ajshedivy
Copy link
Contributor

Looks like #499 reverted some logic in useAppState hook in use-app-state.ts for handling mcp.json cli connection logic from #490.

This pull request updates the logic for auto-connecting to mcp.json provided MCP servers in the useAppState hook. Added code back that fetches the mcp configuration from an API endpoint instead of relying on a global window variable, supports multiple servers, and improves handling for auto-connect scenarios. The main changes are grouped below:

MCP Configuration Loading and Processing:

  • Replaces the use of the global window.MCP_CLI_CONFIG with a fetch call to /api/mcp-cli-config to retrieve the mcp configuration, making it compatible with both development and production environments.
  • Adds support for processing multiple servers from the mcp config, including logic to add each server to the UI and selectively auto-connect based on a filter (autoConnectServer).
  • Improves handling for legacy single-server CLI config mode, maintaining backward compatibility.

Robustness and Logging Enhancements:

  • Introduces a guard (cliConfigProcessedRef) to ensure the mcp config is processed only once per mount, preventing duplicate connections.
  • Expands logging to provide more detailed information about server processing, connection attempts, and error handling during config fetch.

chelojimenez
chelojimenez previously approved these changes Sep 11, 2025
Copy link
Contributor

@chelojimenez chelojimenez left a comment

Choose a reason for hiding this comment

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

lgtm! please run npm prettier-fix before merging

@chelojimenez
Copy link
Contributor

tested with:
npm run build && npm start -- --config ../config.json

@chelojimenez
Copy link
Contributor

created a PR so we update or docs to let devs know about this. we starting an open source repo for community mantained docs at https://docs.mcpjam.com/ if you wanna check it out!

@chelojimenez chelojimenez merged commit d011cca into MCPJam:main Sep 11, 2025
2 checks passed
@chelojimenez
Copy link
Contributor

branch was failing bc our gh check was using a different node version, so i merged this!

khandrew1 pushed a commit that referenced this pull request Nov 15, 2025
* fix: add back client logic for handling mcp.json

* fix: update server handling logic to always add/update from CLI config

* add support for sse/http auto connections from mcp.json

* run prettier script

---------

Co-authored-by: marcelo <[email protected]>
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.

2 participants