Skip to content

Commit ac4d8d8

Browse files
committed
Add documentation for the mcp plugin
1 parent 4213f67 commit ac4d8d8

File tree

4 files changed

+135
-0
lines changed

4 files changed

+135
-0
lines changed

docs/authentication/ai/_category_.json

Whitespace-only changes.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
---
2+
title: Authenticate MCP Servers
3+
hide_title: true
4+
sidebar_position: 1
5+
pagination_next: null
6+
pagination_prev: null
7+
skip_llms_txt: true
8+
description: >-
9+
Authenticate MCP server actions using the SuperTokens MCP plugin
10+
to use with AI tools and agents.
11+
---
12+
13+
# Authenticate MCP Servers
14+
15+
This guide explains how to authenticate MCP Servers using the provided code snippet. Follow the steps below to integrate and initialize your MCP server with SuperTokens.
16+
17+
## Overview
18+
19+
This guide covers the following topics:
20+
21+
- Installing the MCP plugin.
22+
- Initializing the plugin.
23+
- Registering tools.
24+
- Initializing the SDK.
25+
26+
We use a sample code snippet to illustrate the server configuration and how to add administrative tools.
27+
28+
## Before you start
29+
30+
Before setting up your MCP servers, ensure you have:
31+
32+
- Installed the required packages (e.g., **mcp-plugin** and its dependencies).
33+
- Configured your authentication system with SuperTokens.
34+
- Setup your development environment with Node.js.
35+
36+
Review your permission requirements, as the servers validate user roles to authorize access.
37+
38+
## Steps
39+
40+
### 1. Install the plugin
41+
42+
Install the MCP plugin via npm:
43+
44+
```bash
45+
npm install mcp-plugin
46+
```
47+
48+

Ensure that all dependencies for SuperTokens are also installed according to your project requirements.
49+
50+
### 2. Initialize the plugin
51+
52+
In your project file, import the necessary components and initialize your MCP server. The following example shows how to create an instance of ⁠SuperTokensMCPServer and configure its basic parameters:
53+
54+
```ts
55+
import { MCPPlugin, SuperTokensMCPServer, AdminToolMCPServer } from "mcp-plugin";
56+
57+
const mcpServer = new SuperTokensMCPServer({
58+
name: "mcp-server",
59+
version: "1.0.0",
60+
path: "/mcp-server-for-admins",
61+
claimValidators: [{
62+
UserRoles.validate.includesAll("admin")
63+
}],
64+
});
65+
```
66+
67+
### 3. Register your tools
68+
69+
Register the tool with your MCP server. This step involves defining the tool name, description, and an execution function that processes the input and returns an output. The execution function used in the example fetches a user by ID and returns a simple greeting:
70+
71+
```ts
72+
73+
mcpServer.registerTool({
74+
name: "mcp-server",
75+
description: "A tool for the mcp-server",
76+
execute: (toolInput, extra) => {
77+
const { user } = getUserById(extra._meta.accessTokenPayload.sub);
78+
return {
79+
output: "Hello, world!",
80+
};
81+
},
82+
});
83+
```
84+
85+
Create an administrative version of the MCP server using the ⁠AdminToolMCPServer class. This server uses a different claim validator to enforce additional role-based constraints:
86+
87+
88+
### 4. Initialize the SDK
89+
90+
Finally, initialize the SuperTokens SDK and add the MCP plugin to your SuperTokens configuration. The MCP plugin is provided with both the standard and administrative server configurations:
91+
92+
```ts
93+
SuperTokens.init({
94+
plugins: [
95+
new MCPPlugin({
96+
mcpServers: [mcpServer, adminToolMCPServer],
97+
}),
98+
],
99+
})
100+
```
101+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
2+
# Build with AI Tools
3+
4+
## Overview
5+
6+
If you plan on using LLMs to assist in the building of SuperTokens integrations, reference this guide to improve your development experience.
7+
The documentation has various helper tools that can aid you when you are interacting with different AI tools
8+
9+
## Text documentation
10+
11+
You can access all the documentation as plain text markdown files by appending `.md` to the end of any URL.
12+
For example, you can find the plain text version of this page at [https://supertokens.com/docs/quickstart/build-with-ai-tools.md](https://supertokens.com/docs/quickstart/build-with-ai-tools.md).
13+
14+
This plain text format is ideal for AI tools and agents as it:
15+
- Contains fewer formatting tokens.
16+
- Displays content that might otherwise be hidden in the HTML or JavaScript-rendered version (such as content in tabs).
17+
- Maintains a clear markdown hierarchy that LLMs can easily parse and understand.
18+
19+
https://llmstxt.org
20+
21+
### `/llms.txt`
22+
23+
We also host an [/llms.txt file](https://docs.supertokens.com/llms.txt.md) which instructs AI tools and agents on how to retrieve the plain text versions of our pages. The `/llms.txt` file follows an [emerging standard](https://llmstxt.org/) for enhancing content accessibility to LLMs.
24+
25+
26+
Additionally, our documentation pages feature buttons for copying the docs as markdown and for opening the full documentation page in an AI chat interface.
27+
28+
## Model Context Protocol (MCP) Server
29+
30+
You can use the SuperTokens Model Context Protocol (MCP) server if you use AI-enhanced code editors (such as Cursor or Windsurf) or general purpose tools like Claude Desktop.
31+
The MCP server provides AI agents a suite of tools to call the SuperTokens API and search our knowledge base (documentation, support articles, and more).
32+
33+
For a local setup, you can run the [local SuperTokens MCP server](https://github.com/supertokens/agent-toolkit/tree/main/modelcontextprotocol).

0 commit comments

Comments
 (0)