);
}
```
**Setup Requirements:**
1. Use `.tsx` file extension for React component tools
2. Install React dependencies: `npm install react react-dom`
3. Configure `tsconfig.json`:
```json
{
"compilerOptions": {
"jsx": "react-jsx"
}
}
```
## Return Values
Tools support multiple return formats depending on your needs:
### Simple Values
Return strings or numbers directly - xmcp automatically wraps them in the proper format:
```typescript
export default async function calculate() {
return "Result: 42"; // or return 42;
}
```
### Content Array
Return an object with a `content` array for rich media responses:
```typescript
export default async function getProfile() {
return {
content: [
{
type: "text",
text: "Profile information:",
},
{
type: "image",
data: "base64encodeddata",
mimeType: "image/jpeg",
},
{
type: "resource_link",
name: "Full Profile",
uri: "resource://profile/john",
},
],
};
}
```
**Supported content types:**
* `text` - Plain text content
* `image` - Base64-encoded images with mimeType
* `audio` - Base64-encoded audio with mimeType
* `resource_link` - Links to MCP resources
### Structured Outputs
Return structured data using the `structuredContent` property:
```typescript
export default async function getUserData() {
return {
structuredContent: {
user: {
id: 123,
name: "John Doe",
email: "john@example.com",
},
metadata: {
timestamp: new Date().toISOString(),
},
},
};
}
```
### Combined Response
Return both `content` and `structuredContent` for backwards compatibility. If the client cannot process structured outputs, it will fallback to `content`.
```typescript
export default async function getData() {
return {
content: [
{
type: "text",
text: "Data retrieved successfully",
},
],
structuredContent: {
data: { key: "value" },
},
};
}
```
# Alpic (/docs/deployment/alpic)
Get started by bootstrapping a [new project](https://app.alpic.ai/new/clone?repositoryUrl=https://github.com/alpic-ai/mcp-server-template-xmcp).
This command will clone the xmcp template repository and setup zero-configuration deployment to Alpic.
## Deploy an existing project
You can deploy your xmcp server to Alpic in 2 steps:
1. Create a new account on [app.alpic.ai](https://app.alpic.ai/).
2. Connect your Github account to Alpic, and select the repository you want to deploy.
You can then access your servers's specific MCP analytics, logs, and evals in the [Alpic dashboard](https://app.alpic.ai/).
Learn more about deploying xmcp to Alpic in the [Alpic documentation](https://docs.alpic.ai/).
# Replit (/docs/deployment/replit)
Get started by remixing the [xmcp Replit template](https://replit.com/@matt/MCP-on-Replit-TS#README.md).
# Vercel (/docs/deployment/vercel)
First, bootstrap a new project with `npx create-xmcp-app@latest`.
Then, [connect your Git repository](https://vercel.com/new) or [use Vercel CLI](https://vercel.com/docs/cli):
```bash
vc deploy
```
## Get started with Vercel CLI
You can initialize a new xmcp app with Vercel CLI with the following command:
```bash
vc init xmcp
```
This will clone the [xmcp example repository](https://github.com/vercel/vercel/tree/main/examples/xmcp) in a directory called `xmcp`.
Learn more about deploying xmcp to Vercel in the [Vercel documentation](https://vercel.com/docs/frameworks/backend/xmcp).
# Connecting to your server (/docs/getting-started/connecting)
At this point, you can configure to connect to your MCP server on clients like `Cursor` or `Claude Desktop`.
Notice that, unless you start the development server, or have built your project for production, your server will not be shown available.
## HTTP transport
By default, xmcp will use the port `3001`. If you're using a different port, you can change it in your `xmcp.config.ts` file. Read more about configuring transports [here](../configuration/transports).
### Cursor
If you're using the HTTP transport with Cursor, your configuration should look like this:
```json
{
"mcpServers": {
"my-project": {
"url": "http://localhost:3001/mcp"
}
}
}
```
### Claude Desktop
If you're using the HTTP transport with Claude Desktop, your configuration should look like this:
```json
{
"mcpServers": {
"my-project": {
"command": "npx",
"args": ["-y", "mcp-remote", "http://localhost:3001/mcp"]
}
}
}
```
## STDIO transport
If you're using the STDIO transport, your configuration for local development should look like this:
```json
{
"mcpServers": {
"my-project": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/my-project/dist/stdio.js"]
}
}
}
```
# Installation (/docs/getting-started/installation)
## System requirements
Before you begin, make sure your system meets the following requirements:
* Node.js 20 or later.
* macOS, Windows or Linux.
## Automatic installation
The quickest way to get started with xmcp is using `create-xmcp-app`. This CLI tool allows you to scaffold a template project with all the necessary files and dependencies to get you up and running quickly.
To create an xmcp project, run:
```bash
npx create-xmcp-app@latest
```
On installation, you'll see the following prompts: