Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/mcp-use/mcp-use/llms.txt

Use this file to discover all available pages before exploring further.

Overview

mcp-use enables you to build two types of MCP implementations:

MCP Servers

Backend services that expose tools, resources, and prompts to AI agents

MCP Apps

Interactive widgets with UI components that work across ChatGPT, Claude, and other clients

MCP Servers

What are MCP Servers?

MCP Servers are backend services that implement the Model Context Protocol to provide tools, resources, and prompts that AI agents can use. They are headless services focused on functionality rather than presentation.

Key Characteristics

MCP Servers primarily expose tools (functions) that AI agents can call to perform actions:
server.tool({
  name: "search_database",
  description: "Search the product database",
  schema: z.object({
    query: z.string(),
    limit: z.number().optional(),
  }),
}, async ({ query, limit = 10 }) => {
  const results = await db.search(query, limit);
  return text(JSON.stringify(results));
});
MCP Servers return structured data (text, JSON, binary) without any UI components. The AI client decides how to present the data to users.
// Server returns data
return text("Temperature: 72°F");

// Client/AI decides how to display it
Each tool call is typically independent and stateless:
server.tool({
  name: "calculate",
  schema: z.object({ expression: z.string() }),
}, async ({ expression }) => {
  const result = eval(expression);
  return text(`Result: ${result}`);
});
Servers can expose resources for AI agents to read:
server.resource({
  name: "config",
  uri: "app://config",
  title: "Application Configuration",
}, async () => {
  const config = await loadConfig();
  return text(JSON.stringify(config));
});

When to Use MCP Servers

Use MCP Servers when you need:
  • 🛠️ Programmatic access to APIs and services
  • 🤖 Tool-based interactions for AI agents
  • 📋 Data retrieval from databases or files
  • ⚙️ Background processing without UI requirements
  • 🔌 Integration with existing backend services

Example: Simple MCP Server

import { MCPServer, text } from "mcp-use/server";
import { z } from "zod";

const server = new MCPServer({
  name: "weather-server",
  version: "1.0.0",
});

server.tool({
  name: "get_weather",
  description: "Get weather for a city",
  schema: z.object({ city: z.string() }),
}, async ({ city }) => {
  const weather = await fetchWeather(city);
  return text(`${city}: ${weather.temp}°F, ${weather.condition}`);
});

await server.listen(3000);

MCP Apps

What are MCP Apps?

MCP Apps extend MCP Servers with interactive UI widgets that render in AI clients like ChatGPT and Claude. They combine backend functionality with frontend presentation in a unified package.

Key Characteristics

MCP Apps include React components that render in the client:
// resources/weather-display/widget.tsx
import { useWidget } from "mcp-use/react";

export default function WeatherDisplay() {
  const { props } = useWidget<{
    city: string;
    temperature: number;
    condition: string;
  }>();
  
  return (
    <div className="weather-card">
      <h2>{props.city}</h2>
      <div className="temp">{props.temperature}°</div>
      <p>{props.condition}</p>
    </div>
  );
}
Widgets work seamlessly across different AI clients:
  • ChatGPT: Using Apps SDK protocol
  • Claude Desktop: Using MCP Apps Extension
  • Other MCP clients: Auto-adapts to capabilities
server.tool({
  name: "show_weather",
  description: "Display weather widget",
  schema: z.object({ city: z.string() }),
  widget: "weather-display",  // Links to widget
}, async ({ city }) => {
  return widget({
    props: { city, temperature: 72, condition: "Sunny" },
    message: `Weather for ${city}`,
  });
});
Widgets can handle user interactions and call tools:
export default function TaskManager() {
  const { callTool } = useWidget();
  
  const addTask = async (title: string) => {
    await callTool("create_task", { title });
  };
  
  return (
    <button onClick={() => addTask("New task")}>
      Add Task
    </button>
  );
}
Widgets in resources/ directory are auto-discovered:
project/
├── src/
│   └── server.ts
└── resources/
    ├── weather-display/
    │   └── widget.tsx
    └── task-list/
        └── widget.tsx
No manual registration needed!

When to Use MCP Apps

Use MCP Apps when you need:
  • 📊 Data visualization (charts, graphs, dashboards)
  • 🎮 Interactive forms and user input
  • 📋 Rich content display (cards, lists, galleries)
  • 👩‍💻 User-facing interfaces embedded in chat
  • 🎨 Custom styling and branding

Example: MCP App with Widget

import { MCPServer, widget } from "mcp-use/server";
import { z } from "zod";

const server = new MCPServer({
  name: "weather-app",
  version: "1.0.0",
});

server.tool({
  name: "show_weather",
  description: "Display interactive weather widget",
  schema: z.object({ city: z.string() }),
  widget: "weather-display",  // Links to resources/weather-display/widget.tsx
}, async ({ city }) => {
  const weather = await fetchWeather(city);
  
  return widget({
    props: {
      city,
      temperature: weather.temp,
      condition: weather.condition,
      icon: weather.icon,
    },
    message: `Weather in ${city}: ${weather.condition}, ${weather.temp}°F`,
  });
});

await server.listen(3000);

Comparison Table

FeatureMCP ServerMCP App
UI Components❌ No✅ Yes (React widgets)
Tool Exposure✅ Yes✅ Yes
Resource Access✅ Yes✅ Yes
Prompts✅ Yes✅ Yes
Client CompatibilityAll MCP clientsChatGPT, Claude, MCP Apps clients
Use CaseBackend services, data accessInteractive UIs, visualizations
DevelopmentSimple, lightweightRequires widget development
Auto Inspector✅ Yes✅ Yes

Choosing the Right Approach

1

Start with MCP Server

Begin with a basic MCP Server if you:
  • Need simple tool exposure
  • Don’t require UI components
  • Want the simplest implementation
2

Add Widgets Incrementally

Upgrade to MCP App when you:
  • Identify tools that benefit from visualization
  • Want to improve user experience
  • Need interactive components
3

Mix Both Approaches

In the same server, you can have:
  • Some tools return plain text (server-style)
  • Some tools return widgets (app-style)
// Plain tool (no widget)
server.tool({
  name: "calculate",
  schema: z.object({ expr: z.string() }),
}, async ({ expr }) => {
  return text(`Result: ${eval(expr)}`);
});

// Widget-enabled tool
server.tool({
  name: "show_chart",
  schema: z.object({ data: z.array(z.number()) }),
  widget: "chart-display",
}, async ({ data }) => {
  return widget({ props: { data } });
});

Development Workflow

# Create server
npx create-mcp-use-app my-server

# Start development
cd my-server
npm run dev

# Test in inspector
open http://localhost:3000/inspector

Learn More

Build Your First Server

Step-by-step guide to creating an MCP Server

Build MCP Apps

Learn to create interactive widgets for MCP Apps

Tools, Resources, Prompts

Deep dive into MCP primitives

Architecture

Understand the mcp-use framework architecture

Build docs developers (and LLMs) love