Skip to content

Commit bc9824a

Browse files
authored
Toreleon auto config (#30)
* Add SSE support for running MCP servers and enhance add command functionality * Refactor add_command in CLI to simplify configuration handling and remove client-specific logic * Enhance MCPHub CLI by adding functionality to add servers from GitHub repositories, including README parsing with OpenAI for configuration extraction. Update dependencies in pyproject.toml and improve logging and user feedback in CLI commands. * Refactor MCPHub CLI by removing the run_command function and associated argument parsing for running MCP servers. This change simplifies the codebase and prepares for future enhancements. * Enhance MCPHub CLI by adding a new process manager for handling server processes, improving environment variable checks, and implementing progress indicators for various commands. Update dependencies in pyproject.toml to include psutil for process management. * Update .gitignore to include .coverage file and add pytest-cov dependency in pyproject.toml. Remove unused server configuration functions from utils.py and enhance CLI tests for server management commands.
1 parent 171739a commit bc9824a

File tree

13 files changed

+1853
-18191
lines changed

13 files changed

+1853
-18191
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,6 @@ __pycache__/
4848
.cursor/
4949

5050
# cache dir
51-
.mcphub_cache/
51+
.mcphub_cache/
52+
53+
.coverage

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,33 @@ Create a `.mcphub.json` file in your project root:
4949
}
5050
```
5151

52+
### Adding New MCP Servers
53+
54+
You can add new MCP servers in two ways:
55+
56+
1. **Manual Configuration**: Add the server configuration directly to your `.mcphub.json` file.
57+
58+
2. **Automatic Configuration from GitHub**: Use the `add_server_from_repo` method to automatically configure a server from its GitHub repository:
59+
60+
```python
61+
from mcphub import MCPHub
62+
63+
# Initialize MCPHub
64+
hub = MCPHub()
65+
66+
# Add a new server from GitHub
67+
hub.servers_params.add_server_from_repo(
68+
server_name="my-server",
69+
repo_url="https://github.com/username/repo"
70+
)
71+
```
72+
73+
The automatic configuration:
74+
- Fetches the README from the GitHub repository
75+
- Uses OpenAI to analyze the README and extract the server configuration
76+
- Adds the configuration to your `.mcphub.json` file
77+
- Requires an OpenAI API key (set via `OPENAI_API_KEY` environment variable)
78+
5279
### Usage with OpenAI Agents
5380

5481
```python

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ classifiers = [
2121
"Programming Language :: Python :: 3.11",
2222
"Programming Language :: Python :: 3.12",
2323
]
24-
dependencies = []
24+
dependencies = ["pydantic (>=2.11.4,<3.0.0)", "rich (>=14.0.0,<15.0.0)", "openai (>=1.78.0,<2.0.0)", "psutil (>=7.0.0,<8.0.0)"]
2525
requires-python = "<4.0,>=3.10"
2626

2727
[project.optional-dependencies]
@@ -54,4 +54,5 @@ mcphub = "mcphub.cli.commands:main"
5454

5555
[tool.poetry.group.dev.dependencies]
5656
pytest = "^8.3.5"
57-
pytest-asyncio = "^0.26.0"
57+
pytest-asyncio = "^0.26.0"
58+
pytest-cov = "^6.1.1"

0 commit comments

Comments
 (0)