Skip to content

Commit b12fde1

Browse files
authored
Fix issue #14: Clean up Usage section and remove Cursor-specific references (#24)
- Restructured Usage section with clear subsections: Web Interface, MCP Client Integration, and API Usage - Removed Cursor-specific references from MCP Registry MCP Server section - Replaced IDE-specific instructions with generic MCP client configuration patterns - Added programmatic usage examples using code snippets from agent_w_auth.py - Focused on tool-agnostic instructions applicable to various MCP clients - Improved documentation consistency and flow between sections
1 parent 1b2a21f commit b12fde1

File tree

1 file changed

+80
-40
lines changed

1 file changed

+80
-40
lines changed

README.md

Lines changed: 80 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -319,67 +319,107 @@ For production deployments you might want to run this solution on EKS, the [Dist
319319

320320
## Usage
321321

322+
The MCP Gateway & Registry can be used in multiple ways depending on your needs:
323+
324+
### Web Interface Usage
325+
322326
1. **Login:** Use the `ADMIN_USER` and `ADMIN_PASSWORD` specified while starting the Gateway container.
323-
1. **Manage Services:**
327+
2. **Manage Services:**
324328
* Toggle the Enabled/Disabled switch. The Nginx config automatically comments/uncomments the relevant `location` block.
325329
* Click "Modify" to edit service details.
326330
* Click the refresh icon (🔄) in the card header to manually trigger a health check and tool list update for enabled services.
327-
1. **View Tools:** Click the tool count icon (🔧) in the card footer to open a modal displaying discovered tools and their schemas for healthy services.
328-
1. **Filter:** Use the sidebar links to filter the displayed services.
331+
3. **View Tools:** Click the tool count icon (🔧) in the card footer to open a modal displaying discovered tools and their schemas for healthy services.
332+
4. **Filter:** Use the sidebar links to filter the displayed services.
329333

330-
### Interact with the MCP Registry via its own built-in MCP server!
334+
### MCP Client Integration
331335

332-
The MCP Registry provides an [API](#api-endpoints-brief-overview), this API is also exposed as an MCP server so we have an MCP Server to manage the MCP Registry itself. You can use any MCP Host such as [`Cursor`](https://www.cursor.com/) or others that support remote MCP Servers over SSE. To add the MCP Registry's MCP server to Cursor, simply add the following JSON to Cursor's `mcp.json` file.
336+
The MCP Registry provides an [API](#api-endpoints-brief-overview) that is also exposed as an MCP server, allowing you to manage the MCP Registry programmatically. Any MCP client that supports remote MCP servers over SSE can connect to the registry.
333337

334-
>Using the MCP Gateway in Agents and hosts such as Cursor does require that you run the Gateway over HTTPS, see instructions [here](#running-the-gateway-over-https).
338+
#### Configuration for MCP Clients
339+
340+
To connect your MCP client to the registry, use the following configuration pattern:
335341

336342
```json
337343
{
338344
"mcpServers": {
339345
"mcpgw": {
340-
"url": "https://mymcpgateway.mycorp.com//mcpgw/sse"
346+
"url": "https://your-mcp-gateway.com/mcpgw/sse"
341347
}
342348
}
343349
}
344350
```
345351

346-
Cursor should now be able to talk to the MCP Gateway and you should be able to use the tools it provides.
347-
348-
![Cursor MCP server](./docs/img/cursor-mcp-server.png)
352+
> **Note:** Using the MCP Gateway with remote clients requires HTTPS. See instructions [here](#running-the-gateway-over-https) for setting up SSL certificates.
353+
354+
#### Programmatic Access
355+
356+
Once connected, your MCP client can:
357+
- Discover available tools through natural language queries
358+
- Register new MCP servers programmatically
359+
- Manage server configurations
360+
- Monitor server health and status
361+
362+
### API Usage
363+
364+
#### Adding New MCP Servers
365+
366+
**Option 1 - Via MCP Client (_recommended_):**
367+
Connect any MCP client that supports SSE to the registry and use natural language to register new servers. The registry will guide you through the registration process.
368+
369+
**Option 2 - Direct API Access:**
370+
Use the REST API endpoints directly. First authenticate, then use the registration endpoint:
371+
372+
```bash
373+
# Login to get the session cookie
374+
curl -X POST \
375+
-H "Content-Type: application/x-www-form-urlencoded" \
376+
-d "username=admin&password=$ADMIN_PASSWORD" \
377+
-c cookies.txt \
378+
http://localhost:7860/login
379+
380+
# Register a new MCP server
381+
curl -X POST http://localhost:7860/register \
382+
-H "Content-Type: application/x-www-form-urlencoded" \
383+
-b cookies.txt \
384+
--data-urlencode "name=My New Service" \
385+
--data-urlencode "description=A fantastic new service" \
386+
--data-urlencode "path=/new-service" \
387+
--data-urlencode "proxy_pass_url=http://localhost:8004" \
388+
--data-urlencode "tags=new,experimental" \
389+
--data-urlencode "num_tools=2" \
390+
--data-urlencode "num_stars=0" \
391+
--data-urlencode "is_python=true" \
392+
--data-urlencode "license=MIT"
393+
```
349394

350-
### Steps to add a new MCP server to the Gateway and Registry
395+
#### Integration Example
351396

352-
1. Option 1 (_recommended_): Use `Cursor` or your favorite MCP host of choice that supports SSE to add the MCP Gateway as a server as an MCP server and then simple ask it in natural language to register a new MCP server and follow the prompts.
397+
**Python MCP Client:**
398+
```python
399+
import mcp
400+
from mcp.client.sse import sse_client
353401
354-
1. Option 2: Use `/register` API (first call the `/login` API and get the secure cookie value), see steps in the [API endpoints](#api-endpoints-brief-overview) section. Note the value for the `mcp_gateway_session` cookie from the `/login` API and then use it in `/register` API.
355-
```bash
356-
# Login to get the session cookie
357-
curl -X POST \
358-
-H "Content-Type: application/x-www-form-urlencoded" \
359-
-d "username=admin&password=$ADMIN_PASSWORD" \
360-
-c cookies.txt \
361-
http://localhost:7860/login
362-
```
402+
# Connect to the MCP Gateway with authentication
403+
headers = {
404+
'Authorization': f'Bearer {auth_token}',
405+
'X-User-Pool-Id': user_pool_id,
406+
'X-Client-Id': client_id,
407+
'X-Region': region
408+
}
363409
364-
Use the value of the `mcp_gateway_session` in `cookies.txt` in the following command.
365-
```bash
366-
# Set the session cookie value in a variable
367-
SESSION_COOKIE="session-cookie-from-login"
368-
369-
# Use the variable in the curl command
370-
curl -X POST http://localhost:7860/register \
371-
-H "Content-Type: application/x-www-form-urlencoded" \
372-
-b cookies.txt \
373-
--data-urlencode "name=My New Service" \
374-
--data-urlencode "description=A fantastic new service" \
375-
--data-urlencode "path=/new-service" \
376-
--data-urlencode "proxy_pass_url=http://localhost:8004" \
377-
--data-urlencode "tags=new,experimental" \
378-
--data-urlencode "num_tools=2" \
379-
--data-urlencode "num_stars=0" \
380-
--data-urlencode "is_python=true" \
381-
--data-urlencode "license=MIT"
382-
```
410+
async with sse_client(server_url, headers=headers) as (read, write):
411+
async with mcp.ClientSession(read, write) as session:
412+
# Initialize the connection
413+
await session.initialize()
414+
415+
# Call a tool with arguments
416+
result = await session.call_tool(tool_name, arguments=arguments)
417+
418+
# Process the result
419+
response = ""
420+
for r in result.content:
421+
response += r.text + "\n"
422+
```
383423
384424
385425
## API Endpoints (Brief Overview)

0 commit comments

Comments
 (0)