);
}
```
**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/).
# Cloudflare (/docs/deployment/cloudflare)
Cloudflare Workers support is built into xmcp with the `--cf` flag. The easiest path is to bootstrap a project that includes Wrangler and the Cloudflare build pipeline.
## Create a new project
Start with `create-xmcp-app` and the Cloudflare flag (you can also pass `--cloudflare` when cloning an example with `--example`):
```bash
npx create-xmcp-app@latest my-xmcp-app --cloudflare
```
This initializes a Workers-ready setup and wires the following defaults:
* `xmcp build --cf` for production builds
* `xmcp dev --cf` alongside `wrangler dev` for local development
* `wrangler deploy` for deployment
## Build and deploy with the CLI
Build a Cloudflare Workers bundle and emit `worker.js` (plus `wrangler.jsonc` if you don’t already have a Wrangler config):
```bash
pnpm build
# or
xmcp build --cf
```
Then deploy with Wrangler:
```bash
pnpm deploy
# or
npx wrangler deploy
```
## Local development
Run the watcher and Wrangler together:
```bash
pnpm dev
```
This runs `xmcp dev --cf` (to rebuild the Worker output) and `wrangler dev` to serve it locally.
Learn more about deploying Workers in the [Cloudflare Workers documentation](https://developers.cloudflare.com/workers/).
# Replit (/docs/deployment/replit)
Get started by remixing the [xmcp Replit template](https://replit.com/@matt/MCP-on-Replit-TS#README.md).
# Smithery (/docs/deployment/smithery)
You can deploy your MCP server and host it on [Smithery](https://smithery.ai). Learn more about publishing hosted MCP servers [here](https://smithery.ai/docs/build/publish#hosted).
Once you got your xmcp server deployed, you can publish it to [Smithery](https://smithery.ai/docs/build/publish) for added capabilities like distribution and analytics.
Smithery Gateway proxies to your upstream server.
1. Go to [smithery.ai/new](https://smithery.ai/new)
2. Enter your server’s public HTTPS URL
3. Complete the publishing flow