Skip to content

Commit 515becd

Browse files
committed
add guideline to readme
1 parent 1ad04f7 commit 515becd

File tree

3 files changed

+120
-7
lines changed

3 files changed

+120
-7
lines changed

README.md

Lines changed: 94 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,46 @@ if __name__ == "__main__":
117117

118118
## Features
119119

120+
### Server Configuration
121+
122+
- **JSON-based Configuration**: Simple `.mcphub.json` configuration file
123+
- **Environment Variable Support**: Use environment variables in configuration
124+
- **Predefined Servers**: Access to a growing list of pre-configured MCP servers
125+
- **Custom Server Support**: Easy integration of custom MCP servers
126+
127+
Configure your MCP servers in `.mcphub.json`:
128+
129+
```json
130+
{
131+
"mcpServers": {
132+
// TypeScript-based MCP server using NPX
133+
"sequential-thinking-mcp": {
134+
"package_name": "smithery-ai/server-sequential-thinking", // NPM package name
135+
"command": "npx", // Command to run server
136+
"args": [ // Command arguments
137+
"-y",
138+
"@smithery/cli@latest",
139+
"run",
140+
"@smithery-ai/server-sequential-thinking"
141+
]
142+
},
143+
// Python-based MCP server from GitHub
144+
"azure-storage-mcp": {
145+
"package_name": "mashriram/azure_mcp_server", // Package identifier
146+
"repo_url": "https://github.com/mashriram/azure_mcp_server", // GitHub repository
147+
"command": "uv", // Python package manager
148+
"args": ["run", "mcp_server_azure_cmd"], // Run command
149+
"setup_script": "uv pip install -e .", // Installation script
150+
"env": { // Environment variables
151+
"AZURE_STORAGE_CONNECTION_STRING": "${AZURE_STORAGE_CONNECTION_STRING}",
152+
"AZURE_STORAGE_CONTAINER_NAME": "${AZURE_STORAGE_CONTAINER_NAME}",
153+
"AZURE_STORAGE_BLOB_NAME": "${AZURE_STORAGE_BLOB_NAME}"
154+
}
155+
}
156+
}
157+
}
158+
```
159+
120160
### MCP Server Installation and Management
121161

122162
- **Flexible Server Setup**: Supports both TypeScript and Python-based MCP servers
@@ -139,24 +179,72 @@ Provides adapters for popular AI frameworks:
139179
- LangChain
140180
- Autogen
141181

142-
### Server Configuration
182+
```python
183+
from mcphub import MCPHub
143184

144-
- **JSON-based Configuration**: Simple `.mcphub.json` configuration file
145-
- **Environment Variable Support**: Use environment variables in configuration
146-
- **Predefined Servers**: Access to a growing list of pre-configured MCP servers
147-
- **Custom Server Support**: Easy integration of custom MCP servers
185+
async def framework_examples():
186+
hub = MCPHub()
187+
188+
# 1. OpenAI Agents Integration
189+
async with hub.fetch_openai_mcp_server(
190+
mcp_name="sequential-thinking-mcp",
191+
cache_tools_list=True
192+
) as server:
193+
# Use server with OpenAI agents
194+
agent = Agent(
195+
name="Assistant",
196+
mcp_servers=[server]
197+
)
198+
199+
# 2. LangChain Tools Integration
200+
langchain_tools = await hub.fetch_langchain_mcp_tools(
201+
mcp_name="sequential-thinking-mcp",
202+
cache_tools_list=True
203+
)
204+
# Use tools with LangChain
205+
206+
# 3. Autogen Adapters Integration
207+
autogen_adapters = await hub.fetch_autogen_mcp_adapters(
208+
mcp_name="sequential-thinking-mcp"
209+
)
210+
# Use adapters with Autogen
211+
```
148212

149213
### Tool Management
150214

151215
- **Tool Discovery**: Automatically list and manage available tools from MCP servers
152216
- **Tool Caching**: Optional caching of tool lists for improved performance
153217
- **Framework-specific Adapters**: Convert MCP tools to framework-specific formats
154218

219+
Discover and manage MCP server tools:
220+
221+
```python
222+
from mcphub import MCPHub
223+
224+
async def tool_management():
225+
hub = MCPHub()
226+
227+
# List all tools from a specific MCP server
228+
tools = await hub.list_tools(mcp_name="sequential-thinking-mcp")
229+
230+
# Print tool information
231+
for tool in tools:
232+
print(f"Tool Name: {tool.name}")
233+
print(f"Description: {tool.description}")
234+
print(f"Parameters: {tool.parameters}")
235+
print("---")
236+
237+
# Tools can be:
238+
# - Cached for better performance using cache_tools_list=True
239+
# - Converted to framework-specific formats automatically
240+
# - Used directly with AI frameworks through adapters
241+
```
242+
155243
## MCPHub: High-Level Overview
156244

157245
MCPHub simplifies the integration of Model Context Protocol (MCP) servers into AI applications through four main components:
158246

159-
![MCPHub Architecture](https://raw.githubusercontent.com/Cognitive-Stacks/mcphub/refs/heads/write_docs/docs/simple_mcphub_work.png)
247+
![MCPHub Architecture](./docs/simple_mcphub_work.png)
160248

161249
### Core Components
162250

src/mcphub/mcp_servers/servers.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,16 @@ async def make_autogen_mcp_adapters(self, mcp_name: str) -> List[StdioMcpToolAda
192192
adapter = await StdioMcpToolAdapter.from_server_params(server_params, tool.name)
193193
adapters.append(adapter)
194194
return adapters
195+
196+
async def list_tools(self, mcp_name: str) -> List[BaseTool]:
197+
"""
198+
List all tools from an MCP server.
199+
200+
Args:
201+
mcp_name: The name of the MCP server configuration to use
202+
203+
Returns:
204+
List[BaseTool]: List of tools provided by the MCP server
205+
"""
206+
async with self.make_openai_mcp_server(mcp_name, cache_tools_list=True) as server:
207+
return await server.list_tools()

src/mcphub/mcphub.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,16 @@ async def fetch_autogen_mcp_adapters(self, mcp_name: str) -> List[StdioMcpToolAd
6868
Returns:
6969
StdioMcpToolAdapter: The configured MCP adapter
7070
"""
71-
return await self.servers.make_autogen_mcp_adapters(mcp_name)
71+
return await self.servers.make_autogen_mcp_adapters(mcp_name)
72+
73+
async def list_tools(self, mcp_name: str) -> List[BaseTool]:
74+
"""
75+
List all tools from an MCP server.
76+
77+
Args:
78+
mcp_name: The name of the MCP server configuration to use
79+
80+
Returns:
81+
List[BaseTool]: List of tools provided by the MCP server
82+
"""
83+
return await self.servers.list_tools(mcp_name)

0 commit comments

Comments
 (0)