Skip to content

Commit dd2b7ba

Browse files
toreleonCopilothieutrtr
authored
Release version 0.1.10 (#31)
* Toreleon non config mcphub (#21) * Add CI/CD workflows for testing, version bumping, and PyPI publishing; enhance README with development and CI/CD details; implement comprehensive tests for MCPHub and MCPServers functionality. * Enhance CI workflow by installing all extras with Poetry * Refactor CI workflow to include version bumping and streamline package publishing using Poetry * Update README to clarify MCPHub installation options with framework-specific dependencies * Restrict pull request triggers to the release branch only * Update CI workflow to enable fail-fast strategy and restrict Python versions to 3.12 only * Refactor CI workflows to remove version bumping from CI and add tagging functionality; update README for clarity on automatic versioning and tagging process. * Refactor CI workflows to integrate version bumping and ensure proper versioning before publishing; update version-bump workflow to set outputs for new version. * Bump version to 0.1.6 in pyproject.toml * Refactor CI workflows: remove version-bump workflow and integrate version extraction and tagging directly in the publish job; update package version to 0.1.7 in pyproject.toml * Fix test data structure in TestMCPServersParams to match expected format Updated the mock data in the test for _load_predefined_servers_params to reflect the correct structure, ensuring that the "mcpServers" key wraps the predefined server details. This change enhances the accuracy of the test and aligns it with the actual implementation. * Toreleon cli (#22) * Add CI/CD workflows for testing, version bumping, and PyPI publishing; enhance README with development and CI/CD details; implement comprehensive tests for MCPHub and MCPServers functionality. * Enhance CI workflow by installing all extras with Poetry * Refactor CI workflow to include version bumping and streamline package publishing using Poetry * Update README to clarify MCPHub installation options with framework-specific dependencies * Restrict pull request triggers to the release branch only * Update CI workflow to enable fail-fast strategy and restrict Python versions to 3.12 only * Refactor CI workflows to remove version bumping from CI and add tagging functionality; update README for clarity on automatic versioning and tagging process. * Refactor CI workflows to integrate version bumping and ensure proper versioning before publishing; update version-bump workflow to set outputs for new version. * Bump version to 0.1.6 in pyproject.toml * Refactor CI workflows: remove version-bump workflow and integrate version extraction and tagging directly in the publish job; update package version to 0.1.7 in pyproject.toml * Fix test data structure in TestMCPServersParams to match expected format Updated the mock data in the test for _load_predefined_servers_params to reflect the correct structure, ensuring that the "mcpServers" key wraps the predefined server details. This change enhances the accuracy of the test and aligns it with the actual implementation. * Add CLI commands and utilities for MCPHub configuration management - Implemented CLI commands for initializing, adding, removing, and listing MCP servers. - Created utility functions for loading and saving configuration files. - Added tests for CLI commands to ensure proper functionality and error handling. * Enhance test for 'init' command to skip config creation when it exists * Enhance test for 'init' command to skip config creation when it exists (#23) * Enhance test for 'init' command to skip config creation when it exists * Update tests/test_cli.py Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> * Enhance test for 'init' command to skip config creation when it exists (#24) * Refactor dependencies in pyproject.toml to separate optional dependencies and clean up main dependencies section * Toreleon fix dependencies (#25) * Enhance test for 'init' command to skip config creation when it exists * Refactor dependencies in pyproject.toml to separate optional dependencies and clean up main dependencies section * Optional init (#26) * solve test * remove legacy functions * [hot-fix] autogen create_adapters and add examples * update readme * Add SSE support for running MCP servers and enhance add command funct… (#29) * 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 * 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. * Update README and add CLI documentation for MCPHub (#32) - Enhanced README with new documentation section including links to CLI, API, configuration guide, and examples. - Introduced a new README file for the MCPHub CLI, detailing installation, available commands, configuration, features, error handling, and contribution guidelines. * Update src/mcphub/mcp_servers/params.py Co-authored-by: Copilot <[email protected]> * Update src/mcphub/mcp_servers/params.py Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Hiếu Slash <[email protected]>
1 parent d37182c commit dd2b7ba

14 files changed

+2118
-18149
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: 87 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
MCPHub is an embeddable Model Context Protocol (MCP) solution for AI services. It enables seamless integration of MCP servers into any AI framework, allowing developers to easily configure, set up, and manage MCP servers within their applications. Whether you're using OpenAI Agents, LangChain, or Autogen, MCPHub provides a unified way to connect your AI services with MCP tools and resources.
44

5+
## Documentation
6+
7+
- [CLI Documentation](src/mcphub/cli/README.md) - Command-line interface for managing MCP servers
8+
- [API Documentation](docs/api.md) - Python API reference
9+
- [Configuration Guide](docs/configuration.md) - Server configuration details
10+
- [Examples](docs/examples.md) - Usage examples and tutorials
11+
512
## Quick Start
613

714
### Prerequisites
@@ -49,6 +56,33 @@ Create a `.mcphub.json` file in your project root:
4956
}
5057
```
5158

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

5488
```python
@@ -175,20 +209,66 @@ Configure your MCP servers in `.mcphub.json`:
175209
### Transport Support
176210

177211
- **stdio Transport**: Run MCP servers as local subprocesses
212+
- **SSE Transport**: Run MCP servers with Server-Sent Events (SSE) support using supergateway
178213
- **Automatic Path Management**: Manages server paths and working directories
179214
- **Environment Variable Handling**: Configurable environment variables per server
180215

216+
#### Running Servers with SSE Support
217+
218+
You can run MCP servers with SSE support using the `mcphub run` command:
219+
220+
```bash
221+
# Basic usage with default settings
222+
mcphub run your-server-name --sse
223+
224+
# Advanced usage with custom settings
225+
mcphub run your-server-name --sse \
226+
--port 8000 \
227+
--base-url http://localhost:8000 \
228+
--sse-path /sse \
229+
--message-path /message
230+
```
231+
232+
SSE support is useful when you need to:
233+
- Connect to MCP servers from web applications
234+
- Use real-time communication with MCP servers
235+
- Integrate with clients that support SSE
236+
237+
The SSE server provides two endpoints:
238+
- `/sse`: SSE endpoint for real-time updates
239+
- `/message`: HTTP endpoint for sending messages
240+
241+
Example configuration in `.mcphub.json`:
242+
```json
243+
{
244+
"mcpServers": {
245+
"sequential-thinking-mcp": {
246+
"package_name": "smithery-ai/server-sequential-thinking",
247+
"command": "npx",
248+
"args": [
249+
"-y",
250+
"@smithery/cli@latest",
251+
"run",
252+
"@smithery-ai/server-sequential-thinking",
253+
"--key",
254+
"your-api-key"
255+
]
256+
}
257+
}
258+
}
259+
```
260+
181261
### Framework Integration
182262

183263
Provides adapters for popular AI frameworks:
184-
- OpenAI Agents
185-
- LangChain
186-
- Autogen
264+
- OpenAI Agents ([example](examples/with_openai.py))
265+
- LangChain ([example](examples/with_langchain.py))
266+
- Autogen ([example](examples/with_autogen.py))
187267

188268
```python
189269
from mcphub import MCPHub
190270

191-
async def framework_examples():
271+
async def framework_quick_examples():
192272
hub = MCPHub()
193273

194274
# 1. OpenAI Agents Integration
@@ -230,6 +310,9 @@ from mcphub import MCPHub
230310
async def tool_management():
231311
hub = MCPHub()
232312

313+
# List all servers
314+
servers = hub.list_servers()
315+
233316
# List all tools from a specific MCP server
234317
tools = await hub.list_tools(mcp_name="sequential-thinking-mcp")
235318

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"

src/mcphub/cli/README.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# MCPHub CLI
2+
3+
The MCPHub CLI is a command-line interface tool for managing Model Context Protocol (MCP) server configurations. It provides a user-friendly way to add, remove, monitor, and run MCP servers.
4+
5+
## Installation
6+
7+
The CLI is included with the MCPHub package. Install it using pip:
8+
9+
```bash
10+
pip install mcphub
11+
```
12+
13+
## Available Commands
14+
15+
### 1. Add a Server (`add`)
16+
Add a new MCP server from a GitHub repository to your local configuration.
17+
18+
```bash
19+
mcphub add <repo_url> [mcp_name]
20+
```
21+
22+
Options:
23+
- `repo_url`: GitHub repository URL of the MCP server
24+
- `mcp_name` (optional): Custom name for the MCP server
25+
- `-n, --non-interactive`: Skip environment variable prompts
26+
27+
Example:
28+
```bash
29+
mcphub add https://github.com/username/repo my-server
30+
```
31+
32+
### 2. Remove a Server (`remove`)
33+
Remove an MCP server configuration from your local config.
34+
35+
```bash
36+
mcphub remove <mcp_name>
37+
```
38+
39+
Example:
40+
```bash
41+
mcphub remove my-server
42+
```
43+
44+
### 3. List Servers (`ps`)
45+
List all configured MCP servers with detailed process information.
46+
47+
```bash
48+
mcphub ps
49+
```
50+
51+
Shows:
52+
- Server name
53+
- Status (running/not running)
54+
- Ports
55+
- Command
56+
- Creation time
57+
- Uptime
58+
59+
### 4. Check Server Status (`status`)
60+
Show detailed status information for a specific MCP server.
61+
62+
```bash
63+
mcphub status <mcp_name>
64+
```
65+
66+
Example:
67+
```bash
68+
mcphub status my-server
69+
```
70+
71+
### 5. Run a Server (`run`)
72+
Run a configured MCP server with optional SSE support.
73+
74+
```bash
75+
mcphub run <mcp_name> [options]
76+
```
77+
78+
Options:
79+
- `--sse`: Enable Server-Sent Events support
80+
- `--port`: Port for SSE server (default: 3000)
81+
- `--base-url`: Base URL for SSE server (default: http://localhost:3000)
82+
- `--sse-path`: Path for SSE endpoint (default: /sse)
83+
- `--message-path`: Path for message endpoint (default: /message)
84+
85+
Example:
86+
```bash
87+
mcphub run my-server --sse --port 3001
88+
```
89+
90+
## Configuration File
91+
92+
The CLI uses a `.mcphub.json` configuration file in your project directory. Here's an example structure:
93+
94+
```json
95+
{
96+
"mcpServers": {
97+
"server-name": {
98+
"package_name": "package-name",
99+
"command": "command-to-run",
100+
"args": ["arg1", "arg2"],
101+
"env": {
102+
"ENV_VAR": "value"
103+
},
104+
"description": "Server description",
105+
"tags": ["tag1", "tag2"],
106+
"last_run": "timestamp"
107+
}
108+
}
109+
}
110+
```
111+
112+
## Features
113+
114+
- Rich terminal interface with progress bars and colored output
115+
- Interactive prompts for configuration
116+
- Process management and monitoring
117+
- Server-Sent Events (SSE) support
118+
- Environment variable management
119+
- GitHub repository integration
120+
- Detailed status reporting
121+
- Process monitoring and management
122+
123+
## Error Handling
124+
125+
The CLI provides clear error messages and helpful suggestions when something goes wrong. Common error scenarios include:
126+
127+
- Invalid GitHub repository URLs
128+
- Missing environment variables
129+
- Server configuration issues
130+
- Process management errors
131+
132+
## Contributing
133+
134+
To contribute to the CLI development:
135+
136+
1. Fork the repository
137+
2. Create a feature branch
138+
3. Make your changes
139+
4. Add tests for new functionality
140+
5. Submit a pull request
141+
142+
## License
143+
144+
This project is licensed under the MIT License - see the LICENSE file for details.

0 commit comments

Comments
 (0)