|
| 1 | +# Customization Guide |
| 2 | + |
| 3 | +This reference implementation includes demo functionality to showcase MCP features. Here's how to adapt it for your own use case. |
| 4 | + |
| 5 | +## Overview: What to Customize vs. Keep |
| 6 | + |
| 7 | +**Replace with your own:** |
| 8 | +- MCP tools, resources, and prompts (your business logic) |
| 9 | +- Authentication provider (use commercial OAuth provider) |
| 10 | + |
| 11 | +**Keep as-is (infrastructure):** |
| 12 | +- Redis transport and session management |
| 13 | +- HTTP handlers and routing |
| 14 | +- Security middleware and rate limiting |
| 15 | +- Logging infrastructure |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Customizing MCP Functionality |
| 20 | + |
| 21 | +All MCP feature implementations live in **`mcp-server/src/services/mcp.ts`**. This is where you define what your server can do. |
| 22 | + |
| 23 | +### Tools |
| 24 | + |
| 25 | +Replace the 7 demo tools (echo, add, etc.) with your actual tools: |
| 26 | + |
| 27 | +**Location:** `createMcpServer()` function, look for the `CallToolRequestSchema` handler |
| 28 | + |
| 29 | +**What to change:** |
| 30 | +- Tool definitions: name, description, input schema (using Zod) |
| 31 | +- Tool execution logic: what happens when the tool is called |
| 32 | +- Return format: text, images, or embedded resources |
| 33 | + |
| 34 | +**Pattern:** Each tool validates input with a Zod schema and returns content in MCP format. |
| 35 | + |
| 36 | +### Resources |
| 37 | + |
| 38 | +Replace the 100 fake resources with your actual data sources: |
| 39 | + |
| 40 | +**Location:** `createMcpServer()` function, resource-related handlers: |
| 41 | +- `ListResourcesRequestSchema` - List available resources |
| 42 | +- `ReadResourceRequestSchema` - Read specific resources |
| 43 | +- `SubscribeRequestSchema` / `UnsubscribeRequestSchema` - Resource updates |
| 44 | + |
| 45 | +**What to change:** |
| 46 | +- Resource URIs and names |
| 47 | +- Data fetching logic |
| 48 | +- Pagination if needed |
| 49 | +- Update notifications for subscribed resources |
| 50 | + |
| 51 | +**Pattern:** Resources use URIs (e.g., `db://users/123`) and return content as text, JSON, or binary. |
| 52 | + |
| 53 | +### Prompts |
| 54 | + |
| 55 | +Replace the 3 demo prompts with useful prompts for your domain: |
| 56 | + |
| 57 | +**Location:** `createMcpServer()` function, prompt-related handlers: |
| 58 | +- `ListPromptsRequestSchema` - List available prompts |
| 59 | +- `GetPromptRequestSchema` - Return prompt content |
| 60 | + |
| 61 | +**What to change:** |
| 62 | +- Prompt names and descriptions |
| 63 | +- Prompt arguments and validation |
| 64 | +- Prompt content and embedded resources |
| 65 | + |
| 66 | +**Pattern:** Prompts can include dynamic arguments and reference resources. |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +## Customizing Authentication |
| 71 | + |
| 72 | +**Replace the demo auth server** with a commercial OAuth provider (Auth0, Okta, Azure AD, AWS Cognito, Google, GitHub, etc.). |
| 73 | + |
| 74 | +See [OAuth Architecture Patterns](oauth-architecture-patterns.md#using-a-commercial-auth-provider) for detailed integration steps. |
| 75 | + |
| 76 | +**Do not repurpose the demo auth server** - it's designed for development/testing only. Commercial providers offer better security, reliability, and user management. |
| 77 | + |
| 78 | +--- |
| 79 | + |
| 80 | +## Configuration |
| 81 | + |
| 82 | +Update environment variables for your deployment: |
| 83 | + |
| 84 | +**MCP Server** (`mcp-server/.env`): |
| 85 | +```bash |
| 86 | +BASE_URI=https://your-mcp-server.com |
| 87 | +PORT=443 |
| 88 | +AUTH_SERVER_URL=https://your-tenant.auth0.com |
| 89 | +REDIS_URL=redis://your-redis-server:6379 |
| 90 | +``` |
| 91 | + |
| 92 | +**Auth Server** (only if using the demo server for development): |
| 93 | +```bash |
| 94 | +AUTH_SERVER_URL=http://localhost:3001 |
| 95 | +BASE_URI=https://your-mcp-server.com |
| 96 | +``` |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## Testing Your Customizations |
| 101 | + |
| 102 | +1. **Unit tests:** Add tests for your tools/resources in `mcp-server/src/services/` |
| 103 | +2. **Integration tests:** Test with MCP Inspector or client.js |
| 104 | +3. **Build and lint:** Run `npm run build && npm run lint` |
| 105 | +4. **End-to-end:** Use the examples to verify OAuth and MCP flows |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +## Next Steps |
| 110 | + |
| 111 | +1. Fork/clone this repository |
| 112 | +2. Replace tools, resources, and prompts in `mcp-server/src/services/mcp.ts` |
| 113 | +3. Integrate with your OAuth provider (see OAuth Architecture Patterns doc) |
| 114 | +4. Update environment variables for your deployment |
| 115 | +5. Test thoroughly before deploying |
| 116 | + |
| 117 | +For questions about the MCP protocol itself, see the [MCP specification](https://modelcontextprotocol.io/specification). |
0 commit comments