|
1 | 1 | # Topcoder Model Context Protocol (MCP) Server |
| 2 | + |
| 3 | +## Authentication Based Access via Guards |
| 4 | + |
| 5 | +Tools/Resources/Prompts support authentication via TC JWT and/or M2M JWT. Providing JWT in the requests to the MCP server will result in specific listings and bahavior based on JWT access level/roles/permissions. |
| 6 | + |
| 7 | +#### Using `authGuard` - requires TC jwt presence for access |
| 8 | + |
| 9 | +```ts |
| 10 | + @Tool({ |
| 11 | + name: 'query-tc-challenges-private', |
| 12 | + description: |
| 13 | + 'Returns a list of Topcoder challenges based on the query parameters.', |
| 14 | + parameters: QUERY_CHALLENGES_TOOL_PARAMETERS, |
| 15 | + outputSchema: QUERY_CHALLENGES_TOOL_OUTPUT_SCHEMA, |
| 16 | + annotations: { |
| 17 | + title: 'Query Public Topcoder Challenges', |
| 18 | + readOnlyHint: true, |
| 19 | + }, |
| 20 | + canActivate: authGuard, |
| 21 | + }) |
| 22 | +``` |
| 23 | + |
| 24 | +#### Using `checkHasUserRole(Role.Admin)` - TC Role based guard |
| 25 | + |
| 26 | +```ts |
| 27 | + @Tool({ |
| 28 | + name: 'query-tc-challenges-protected', |
| 29 | + description: |
| 30 | + 'Returns a list of Topcoder challenges based on the query parameters.', |
| 31 | + parameters: QUERY_CHALLENGES_TOOL_PARAMETERS, |
| 32 | + outputSchema: QUERY_CHALLENGES_TOOL_OUTPUT_SCHEMA, |
| 33 | + annotations: { |
| 34 | + title: 'Query Public Topcoder Challenges', |
| 35 | + readOnlyHint: true, |
| 36 | + }, |
| 37 | + canActivate: checkHasUserRole(Role.Admin), |
| 38 | + }) |
| 39 | +``` |
| 40 | + |
| 41 | +#### Using `canActivate: checkM2MScope(M2mScope.QueryPublicChallenges)` - M2M based access via scopes |
| 42 | + |
| 43 | +```ts |
| 44 | + @Tool({ |
| 45 | + name: 'query-tc-challenges-m2m', |
| 46 | + description: |
| 47 | + 'Returns a list of Topcoder challenges based on the query parameters.', |
| 48 | + parameters: QUERY_CHALLENGES_TOOL_PARAMETERS, |
| 49 | + outputSchema: QUERY_CHALLENGES_TOOL_OUTPUT_SCHEMA, |
| 50 | + annotations: { |
| 51 | + title: 'Query Public Topcoder Challenges', |
| 52 | + readOnlyHint: true, |
| 53 | + }, |
| 54 | + canActivate: checkM2MScope(M2mScope.QueryPublicChallenges), |
| 55 | + }) |
| 56 | +``` |
0 commit comments