Skip to content

Commit 8bebf93

Browse files
committed
docs: clarify instructions
1 parent 876228b commit 8bebf93

3 files changed

Lines changed: 45 additions & 142 deletions

File tree

β€ŽREADME.mdβ€Ž

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ Refer to [docs](https://docs.keycard.ai/) on how to signup. Navigate to Zone Set
6363

6464
![Keycard ZoneId Information](docs/images/keycard_zone_information.png)
6565

66+
### Configure Your prefered Identity Provider
67+
68+
![Keycard Identity Provider Configuration](docs/images/keycard_identity_provider_config.png)
69+
6670
### Setup MCP resource
6771

6872
![Create MCP Resource](docs/images/create_mcp_resource.png)
@@ -114,14 +118,13 @@ pip install uvicorn
114118
uvicorn server:app
115119
```
116120

117-
Your MCP server is now running with KeyCard authentication! πŸŽ‰
118-
119-
120121
### Authenticate in client
121122

122123
![Cursor Authentication Prompt](docs/images/cursor_authenticate.png)
123124

124-
> **Need a KeyCard zone?** Sign up at [keycard.cloud](https://keycard.cloud) to get your zone ID and start building secure MCP applications.
125+
126+
### πŸŽ‰ Your MCP server is now running with KeyCard authentication! πŸŽ‰
127+
125128

126129
## Overview
127130

73.5 KB
Loading

β€Žpackages/mcp/README.mdβ€Ž

Lines changed: 38 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -10,171 +10,71 @@ pip install keycardai-mcp
1010

1111
## Quick Start
1212

13-
```python
14-
from keycardai.mcp import *
15-
16-
# MCP Server with authentication
17-
server = MCPServer(
18-
name="my-mcp-server",
19-
version="1.0.0",
20-
auth_config=MCPAuthConfig(
21-
oauth_client_id="your_client_id",
22-
oauth_client_secret="your_client_secret"
23-
)
24-
)
13+
Add KeyCard authentication to your existing MCP server:
2514

26-
# Register authenticated resources
27-
@server.resource("user-data")
28-
async def get_user_data(context: MCPContext) -> MCPResource:
29-
# Automatic token validation and user context
30-
user = context.authenticated_user
31-
return MCPResource(
32-
uri=f"user://{user.id}/data",
33-
content=await fetch_user_data(user.id)
34-
)
35-
36-
# MCP Client with token management
37-
client = MCPClient(
38-
server_url="https://api.example.com/mcp",
39-
auth=MCPOAuthAuth(
40-
client_id="client_id",
41-
client_secret="client_secret"
42-
)
43-
)
15+
### Install the Package
4416

45-
# Access authenticated resources
46-
user_data = await client.get_resource("user-data")
17+
```bash
18+
pip install keycardai-mcp
4719
```
4820

49-
## πŸ—οΈ Architecture & Features
50-
51-
This SDK provides comprehensive MCP functionality with enterprise-grade security:
52-
53-
### Core MCP Components
21+
### Get Your KeyCard Zone ID
5422

55-
| Component | Module | Description |
56-
|-----------|---------|-------------|
57-
| **MCP Server** | `server.py` | **Authenticated MCP Server** - Host MCP resources with built-in OAuth 2.0 authentication |
58-
| **MCP Client** | `client.py` | **Secure MCP Client** - Connect to MCP servers with automatic token management |
59-
| **Resource Management** | `resources.py` | **Authenticated Resources** - Secure resource access with user context |
60-
| **Tool Integration** | `tools.py` | **Secure Tools** - Execute MCP tools with proper authorization |
23+
1. Sign up at [keycard.ai](https://keycard.ai)
24+
2. Navigate to Zone Settings to get your zone ID
25+
3. Configure your preferred identity provider
26+
4. Create an MCP resource in your zone
6127

62-
### Authentication & Security
28+
### Add Authentication to Your MCP Server
6329

64-
| Feature | Module | Description |
65-
|---------|---------|-------------|
66-
| **OAuth 2.0 Integration** | `auth.py` | **Token Management** - Seamless OAuth integration for MCP operations |
67-
| **Token Validation** | `validation.py` | **Security Middleware** - Automatic token validation and user context |
68-
| **Scope Management** | `scopes.py` | **Permission Control** - Fine-grained access control for MCP resources |
69-
| **Session Management** | `sessions.py` | **Secure Sessions** - Persistent authenticated sessions for MCP clients |
70-
71-
### MCP Protocol Extensions
72-
73-
| Standard | Module | Description |
74-
|----------|---------|-------------|
75-
| **Resource Templates** | `templates.py` | **Dynamic Resources** - Template-based resource generation with auth context |
76-
| **Prompt Security** | `prompts.py` | **Secure Prompts** - User-aware prompt templates and execution |
77-
| **Tool Authorization** | `tools.py` | **Permission Checks** - Role-based access control for MCP tools |
78-
| **Logging & Monitoring** | `monitoring.py` | **Security Audit** - Comprehensive logging of authenticated operations |
79-
80-
## Features
30+
```python
31+
from mcp.server.fastmcp import FastMCP
32+
from keycardai.mcp.server.auth import AuthProvider
8133

82-
- βœ… **MCP Protocol Compliance**: Full implementation of Model Context Protocol standards
83-
- βœ… **OAuth 2.0 Integration**: Seamless authentication with industry-standard OAuth flows
84-
- βœ… **Type Safe**: Full type hints with Pydantic models for all MCP operations
85-
- βœ… **Async Support**: Native async/await support for all MCP operations
86-
- βœ… **Enterprise Security**: Token validation, scope management, and audit logging
87-
- βœ… **Developer Friendly**: Simplified API that abstracts away authentication complexity
88-
- βœ… **Production Ready**: Battle-tested security patterns and comprehensive error handling
34+
# Your existing MCP server
35+
mcp = FastMCP("My Secure MCP Server")
8936

90-
## Use Cases
37+
@mcp.tool()
38+
def my_protected_tool(data: str) -> str:
39+
return f"Processed: {data}"
9140

92-
### πŸ€– AI Agent Platforms
93-
```python
94-
# Secure MCP server for AI agents
95-
server = MCPServer(auth_required=True)
96-
97-
@server.tool("execute-query")
98-
async def execute_query(context: MCPContext, query: str) -> dict:
99-
# Only authenticated users with 'query:execute' scope
100-
if not context.has_scope("query:execute"):
101-
raise MCPAuthError("Insufficient permissions")
102-
103-
return await database.execute(query, user=context.user)
104-
```
105-
106-
### πŸ” Enterprise LLM Integration
107-
```python
108-
# Corporate LLM with secure resource access
109-
client = MCPClient(
110-
server_url="https://corp-llm.company.com/mcp",
111-
auth=MCPOAuthAuth.from_client_credentials(
112-
client_id="corp-client",
113-
client_secret="secret",
114-
scopes=["documents:read", "calendar:read"]
115-
)
41+
# Add KeyCard authentication
42+
access = AuthProvider(
43+
zone_id="your_zone_id_here",
44+
mcp_server_name="My Secure MCP Server",
11645
)
11746

118-
# Access corporate resources securely
119-
documents = await client.list_resources("documents")
47+
# Create authenticated app
48+
app = access.app(mcp)
12049
```
12150

122-
### 🌐 Multi-Tenant SaaS
123-
```python
124-
# Tenant-aware MCP resources
125-
@server.resource("tenant-data")
126-
async def get_tenant_data(context: MCPContext) -> MCPResource:
127-
tenant_id = context.user.tenant_id
128-
return await fetch_tenant_data(tenant_id, user=context.user)
129-
```
130-
131-
## Security Best Practices
132-
133-
### Token Management
134-
- Automatic token refresh and rotation
135-
- Secure token storage with encryption
136-
- Scope-based permission validation
137-
- Session timeout and cleanup
138-
139-
### Authentication Flows
140-
- Authorization Code flow for web applications
141-
- Client Credentials flow for service-to-service
142-
- Device Code flow for CLI applications
143-
- PKCE for public clients
51+
### Run with Authentication
14452

145-
### Monitoring & Compliance
146-
- Comprehensive audit logging
147-
- Rate limiting and abuse prevention
148-
- GDPR-compliant user data handling
149-
- SOC 2 security controls
150-
151-
## Development
53+
```bash
54+
pip install uvicorn
55+
uvicorn server:app
56+
```
15257

153-
This package is part of the [KeycardAI Python SDK workspace](../../README.md).
58+
### πŸŽ‰ Your MCP server is now protected with KeyCard authentication! πŸŽ‰
15459

155-
To develop:
60+
## Features
15661

157-
```bash
158-
# From workspace root
159-
uv sync
160-
uv run --package keycardai-mcp pytest
161-
```
62+
- βœ… **OAuth 2.0 Authentication**: Secure your MCP server with industry-standard OAuth flows
63+
- βœ… **Easy Integration**: Add authentication with just a few lines of code
64+
- βœ… **Multi-Zone Support**: Support multiple KeyCard zones in one application
65+
- βœ… **Token Exchange**: Automatic delegated token exchange for accessing external APIs
66+
- βœ… **Production Ready**: Battle-tested security patterns and error handling
16267

16368
## Examples
16469

165-
See the [examples directory](examples/) for comprehensive examples including:
166-
- Basic MCP server setup
167-
- OAuth integration patterns
168-
- Multi-tenant configurations
169-
- Enterprise deployment guides
70+
For complete examples and advanced usage patterns, see our [documentation](https://docs.keycard.ai).
17071

17172
## License
17273

17374
MIT License - see [LICENSE](../../LICENSE) file for details.
17475

17576
## Support
17677

177-
- πŸ“– [Documentation](https://docs.keycardai.com/mcp)
78+
- πŸ“– [Documentation](https://docs.keycard.ai)
17879
- πŸ› [Issue Tracker](https://github.com/keycardai/python-sdk/issues)
179-
- πŸ’¬ [Community Discussions](https://github.com/keycardai/python-sdk/discussions)
18080
- πŸ“§ [Support Email](mailto:support@keycard.ai)

0 commit comments

Comments
Β (0)