### Install Dependencies
Source: https://docs.civic.com/guides/add-auth-to-mcp
Installs the necessary libraries for MCP server setup and Civic Auth integration.
```bash
npm install @modelcontextprotocol/sdk @civic/auth-mcp zod
```
--------------------------------
### Install civic-mcp-client
Source: https://docs.civic.com/civic/recipes/civic-mcp-client-python
Install the base package using pip.
```bash
pip install civic-mcp-client
```
--------------------------------
### Install Civic VS Code Client
Source: https://docs.civic.com/civic/quickstart/clients/vscode
Use this URL to manually install the Civic VS Code client if the direct install button fails. Ensure VS Code is installed and accessible.
```url
vscode:mcp/install?%7B%22name%22%3A%22Civic%22%2C%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40civic%2Fhub-bridge%22%5D%7D
```
--------------------------------
### Install Node.js with winget (Windows)
Source: https://docs.civic.com/civic/quickstart/hub-bridge
Use winget to install Node.js on Windows. Ensure Node.js 18 or higher is installed.
```powershell
# Using winget
winget install OpenJS.NodeJS
# Or download from nodejs.org
```
--------------------------------
### Install optional framework integrations
Source: https://docs.civic.com/civic/recipes/civic-mcp-client-python
Install the client with support for specific frameworks like LangChain, Pydantic AI, or FastMCP.
```bash
pip install "civic-mcp-client[langchain,pydanticai,fastmcp]"
```
--------------------------------
### Install Civic Auth Verify Library
Source: https://docs.civic.com/integration/react
Install the `@civic/auth-verify` library on your backend to verify token signatures.
```bash
npm install @civic/auth-verify
```
--------------------------------
### Install Civic Auth with FastAPI Support
Source: https://docs.civic.com/integration/python
Install the Civic Auth Python SDK with support for FastAPI.
```bash
pip install "civic-auth[fastapi]"
```
--------------------------------
### Install @civic/auth-verify with pnpm
Source: https://docs.civic.com/libraries/auth-verify
Install the package using pnpm.
```bash
pnpm add @civic/auth-verify
```
--------------------------------
### Install Civic Auth with Django Support
Source: https://docs.civic.com/integration/python
Install the Civic Auth Python SDK with support for Django.
```bash
pip install "civic-auth[django]"
```
--------------------------------
### Install @civic/auth-verify with yarn
Source: https://docs.civic.com/libraries/auth-verify
Install the package using yarn.
```bash
yarn add @civic/auth-verify
```
--------------------------------
### Install civic-auth Python Library
Source: https://docs.civic.com/civic/recipes/pydantic-ai
Install the civic-auth library to handle user authentication for web applications.
```bash
pip install civic-auth
```
--------------------------------
### Start the Server
Source: https://docs.civic.com/civic/recipes/deepagents
Run the FastAPI application using uvicorn. This command starts the development server with hot-reloading enabled.
```bash
uv run uvicorn main:app --reload
```
--------------------------------
### Install Mastra Packages
Source: https://docs.civic.com/civic/recipes/mastra
Install the necessary Mastra packages using pnpm.
```bash
pnpm add @mastra/mcp @mastra/core @ai-sdk/anthropic
```
--------------------------------
### Install Civic Auth with Flask Support
Source: https://docs.civic.com/integration/python
Install the Civic Auth Python SDK with support for Flask.
```bash
pip install "civic-auth[flask]"
```
--------------------------------
### Install MCP Hub Client Package
Source: https://docs.civic.com/public-labs
Use npm to install the MCP Hub client package. This is a prerequisite for using the client in your project.
```bash
npm install @civic/mcp-hub-client
```
--------------------------------
### Install Agno and Dependencies
Source: https://docs.civic.com/civic/recipes/agno
Install the agno library along with anthropic and python-dotenv for environment variable management.
```bash
pip install agno anthropic python-dotenv
```
--------------------------------
### Install Node.js on Ubuntu/Debian
Source: https://docs.civic.com/civic/quickstart/hub-bridge
Install Node.js and npm on Ubuntu/Debian systems. Consider using NodeSource for the latest versions.
```bash
# Ubuntu/Debian
sudo apt update && sudo apt install nodejs npm
# Or use NodeSource repository for latest version
```
--------------------------------
### Install AI SDK and Civic Auth Packages
Source: https://docs.civic.com/civic/recipes/vercel-ai-sdk
Install the necessary packages for AI SDK and Civic authentication in your Next.js project.
```bash
pnpm install ai @ai-sdk/openai @ai-sdk/anthropic @ai-sdk/react @modelcontextprotocol/sdk @civic/auth
```
--------------------------------
### Install OpenAI SDK and Civic MCP
Source: https://docs.civic.com/civic/recipes/openai-sdk
Install the required npm packages for the OpenAI SDK and Civic MCP.
```bash
npm install openai @modelcontextprotocol/sdk
```
--------------------------------
### Install langgraph, langchain-anthropic, and langchain-mcp-adapters
Source: https://docs.civic.com/civic/recipes/langchain
Install the necessary Python packages for LangGraph, Anthropic LLM, and Civic MCP adapters.
```bash
pip install langgraph langchain-anthropic langchain-mcp-adapters
```
--------------------------------
### Example Connection URLs with Query Parameters
Source: https://docs.civic.com/civic/quickstart/clients/agents
Demonstrates various ways to construct connection URLs for agents using different query parameters to specify toolkits, lock behavior, and load additional skills.
```url
https://app.civic.com/hub/mcp?profile=sales-agent
```
```url
https://app.civic.com/hub/mcp?profile=assistant&lock=false
```
```url
https://app.civic.com/hub/mcp?profile=support&skills=escalation,triage
```
```url
https://app.civic.com/hub/mcp?profile=ops&accountId=org_abc123
```
--------------------------------
### Complete FastAPI App Example
Source: https://docs.civic.com/integration/python/fastapi
A comprehensive example of a FastAPI application integrating Civic Auth, including configuration, route creation, and dependency setup. This serves as a full-fledged template for your project.
```python
from fastapi import FastAPI, Depends, Request
from fastapi.responses import RedirectResponse
from civic_auth.integrations.fastapi import create_auth_router, create_auth_dependencies
app = FastAPI(title="My Civic Auth App")
# Configuration
config = {
"client_id": "YOUR_CLIENT_ID", # Replace with your actual client ID
"redirect_url": "http://localhost:8000/auth/callback",
"post_logout_redirect_url": "http://localhost:8000/"
}
```
--------------------------------
### Get User Info with Hono
Source: https://docs.civic.com/integration/nodejs
This example demonstrates how to fetch user details within a Hono application. A custom `CookieStorage` implementation is required.
```javascript
import { CivicAuth } from "@civic/auth/server";
app.get('/admin/hello', async (c) => {
// You need to provide a class implementing the CookieStorage interface,
// telling Civic how to load and store cookies.
// See the Hono page for an example:
// https://docs.civic.com/integration/nodejs/hono#4-set-up-cookies
const yourCookieStorageInstance = new HonoCookieStorage();
const civicAuth = new CivicAuth(yourCookieStorageInstance);
const user = await civicAuth.getUser();
return c.text(`hello ${user.name}!`);
});
```
--------------------------------
### Load Civic Setup Skill via URL Parameter
Source: https://docs.civic.com/civic/concepts/setup-skill
Add the 'skills=civic-setup' parameter to your MCP URL to load the skill.
```url
https://app.civic.com/hub/mcp?skills=civic-setup
```
--------------------------------
### Basic MCP Client Setup with Payments
Source: https://docs.civic.com/labs/private/x402-mcp
Create an MCP client that automatically handles payments. Set up a wallet, create a payment-aware transport, and connect the MCP client.
```typescript
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { makePaymentAwareClientTransport } from "@civic/x402-mcp";
import { createWalletClient, http, publicActions } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { baseSepolia } from "viem/chains";
// Set up wallet with public actions
const wallet = createWalletClient({
account: privateKeyToAccount(process.env.PRIVATE_KEY),
chain: baseSepolia,
transport: http()
}).extend(publicActions);
// Create payment-aware transport
const transport = makePaymentAwareClientTransport(
"http://localhost:3000/mcp",
wallet,
(txHash) => console.log("Payment sent:", txHash) // Optional callback
);
// Connect MCP client
const client = new Client(
{ name: "my-client", version: "1.0.0" },
{ capabilities: {} }
);
await client.connect(transport);
// Use tools normally - payments happen automatically
const result = await client.request({
method: "tools/call",
params: {
name: "expensive-analysis",
arguments: { data: "..." }
}
});
```
--------------------------------
### Quick Start: Verify a Civic Auth Token
Source: https://docs.civic.com/libraries/auth-verify
The simplest way to verify a Civic Auth token. This example uses the default Civic Auth issuer.
```typescript
import { verify } from '@civic/auth-verify';
// Verify a token (uses Civic Auth issuer by default)
try {
const payload = await verify(token);
console.log('User ID:', payload.sub);
console.log('Email:', payload.email);
console.log('Name:', payload.name);
} catch (error) {
console.error('Token verification failed:', error);
}
```
--------------------------------
### Civic Auth with OAuth 4 WebAPI Example
Source: https://docs.civic.com/integration/other
This HTML and JavaScript example demonstrates how to use Civic Auth with the OAuth 4 WebAPI library for a client-side login flow. It includes discovery, PKCE challenge generation, authorization URL creation, and processing the authorization response to get user information.
```html
```
--------------------------------
### Clone Repository and Install Dependencies
Source: https://docs.civic.com/civic/recipes/ciana-parrot
Clone the CianaParrot reference implementation repository and navigate into the project directory. This is the first step before setting up the environment variables and running the application with Docker.
```bash
git clone https://github.com/civicteam/ciana-parrot-reference-implementation-civic.git
cd ciana-parrot-reference-implementation-civic
```
--------------------------------
### AI Prompt Usage Examples
Source: https://docs.civic.com/civic/concepts/tools-resources-prompts
Shows how an AI leverages pre-written prompts to guide its actions and analysis, ensuring structured and effective execution of tasks like code reviews or meeting summaries.
```text
You: "Review this pull request"
AI: [Uses code review prompt] Systematically checks security, performance, style, and provides structured feedback
You: "Summarize today's standup"
AI: [Uses meeting summary prompt] Creates organized summary with decisions, action items, blockers
```
--------------------------------
### Example MCP URLs
Source: https://docs.civic.com/civic/quickstart/credentials
These examples demonstrate various configurations for the MCP URL, including locking to a specific toolkit, pre-loading skills, and specifying an organization account.
```text
# Lock to the "sales-agent" toolkit (recommended for production)
https://app.civic.com/hub/mcp?profile=sales-agent
# Load a toolkit and pre-load skills
https://app.civic.com/hub/mcp?profile=support&skills=escalation,triage
# Organization account with a specific toolkit
https://app.civic.com/hub/mcp?profile=ops&accountId=org_abc123
```
--------------------------------
### Be Explicit in Prompts
Source: https://docs.civic.com/civic/concepts/tips
Vague prompts lead to wasted tokens. Specify tools, data, and criteria clearly. Use examples like 'Get my GitHub notifications from the last 24 hours' instead of 'Check my stuff'.
```text
❌ "Check my stuff"
```
```text
✅ "Get my GitHub notifications from the last 24 hours"
```
```text
✅ "Show all Jira tickets assigned to me in 'In Progress' status"
```
--------------------------------
### Full React Example with Civic Auth and Wallet Balance
Source: https://docs.civic.com/web3/solana
A comprehensive React example showing the integration of Civic Auth and the Solana Wallet Adapter, including fetching and displaying the wallet's SOL balance.
```typescript
import { ConnectionProvider, WalletProvider, useWallet, useConnection } from "@solana/wallet-adapter-react";
import { WalletModalProvider} from "@solana/wallet-adapter-react-ui";
import { CivicAuthProvider } from "@civic/auth-web3/react";
import { FC, useState } from "react";
// Wrap the content with the necessary providers to give access to hooks: solana wallet adapter & civic auth provider
const App = () => {
const endpoint = "YOUR RPC ENDPOINT";
return (
);
};
// A simple hook to get the wallet's balance in lamports
const useBalance = () => {
const [balance, setBalance] = useState();
// The Solana Wallet Adapter hooks
const { connection } = useConnection();
const { publicKey } = useWallet();
if (publicKey) {
connection.getBalance(publicKey).then(setBalance);
}
return balance;
};
// Separate component for the app content that needs access to hooks
const AppContent = () => {
// Get the Solana wallet balance
const balance = useBalance();
// Get the Solana address
const { publicKey } = useWallet();
return (
<>
{publicKey && (
)}
>
);
};
export default App;
```
--------------------------------
### Set up Solana Wallet Adapter with Civic Auth Provider
Source: https://docs.civic.com/web3/solana
A minimal React example demonstrating how to wrap your application with the necessary providers for the Solana Wallet Adapter and Civic Auth.
```typescript
export const Providers: FC = () => {
const endpoint = "YOUR RPC ENDPOINT";
return (
{ /* Your app's components go here */ }
);
};
```
--------------------------------
### Install Node.js with Homebrew (macOS)
Source: https://docs.civic.com/civic/quickstart/hub-bridge
Use Homebrew to install Node.js on macOS. Ensure Node.js 18 or higher is installed.
```bash
# Using Homebrew (recommended)
brew install node
# Or download from nodejs.org
```
--------------------------------
### Generic MCP Client Setup (Python)
Source: https://docs.civic.com/civic/quickstart/ai-prompt
Sets up a generic MCP client using Python for interacting with Civic services. Requires the 'mcp' package and environment variables for URL and token.
```python
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async with streamablehttp_client(
url=os.environ["CIVIC_URL"],
headers={"Authorization": f"Bearer {os.environ['CIVIC_TOKEN']}"}
) as (read, write, _):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await session.list_tools()
# Use tools with your framework's tool-calling mechanism
```
--------------------------------
### Install Hermes Agent with MCP
Source: https://docs.civic.com/civic/recipes/hermes
Install the Hermes agent with MCP support using uv. Ensure Python 3.11+ is installed.
```bash
uv add hermes-agent[mcp]
```
--------------------------------
### Connect and Run Agent with Go ADK
Source: https://docs.civic.com/civic/recipes/google-adk
Initialize the Gemini model, configure the HTTP client with the bearer transport, set up the MCP Toolset, and create an agent. This code demonstrates running the agent and printing its response.
```go
func main() {
ctx := context.Background()
civicURL := os.Getenv("CIVIC_URL")
civicToken := os.Getenv("CIVIC_TOKEN")
llm, _ := gemini.NewModel(ctx, "gemini-2.5-flash", &genai.ClientConfig{
APIKey: os.Getenv("GOOGLE_API_KEY"),
})
httpClient := &http.Client{
Transport: &bearerTransport{token: civicToken, base: http.DefaultTransport},
}
transport := &mcp.StreamableClientTransport{
Endpoint: civicURL,
HTTPClient: httpClient,
DisableStandaloneSSE: true,
}
mcpTools, _ := mcptoolset.New(mcptoolset.Config{Transport: transport})
root, _ := llmagent.New(llmagent.Config{
Name: "civic_assistant",
Instruction: "You are a helpful assistant. Use the available tools when they can help.",
Model: llm,
Toolsets: []tool.Toolset{mcpTools},
})
sessionSvc := session.InMemoryService()
r, _ := runner.New(runner.Config{
AppName: "civic-adk-go",
Agent: root,
SessionService: sessionSvc,
})
sess, _ := sessionSvc.Create(ctx, &session.CreateRequest{
AppName: "civic-adk-go",
UserID: "user-1",
})
userContent := &genai.Content{
Role: "user",
Parts: []*genai.Part{{Text: "What tools do you have?"}},
}
for event, err := range r.Run(ctx, "user-1", sess.Session.ID(), userContent, nil) {
if err != nil || event == nil || event.Content == nil {
continue
}
for _, part := range event.Content.Parts {
if part.Text != "" {
fmt.Print(part.Text)
}
}
}
}
```
--------------------------------
### Install Hub Bridge for Claude Code
Source: https://docs.civic.com/civic/concepts/connection-methods
Use this command to install the Hub Bridge specifically for Claude Code. Ensure you have Node.js and npm installed.
```bash
npx @civic/hub-bridge install claude-code
```
--------------------------------
### Install Civic Auth with FastAPI using uv
Source: https://docs.civic.com/integration/python
Install the Civic Auth Python SDK with support for FastAPI using the uv package manager.
```bash
uv add "civic-auth[fastapi]"
```
--------------------------------
### Basic MCP Server Setup with Payments
Source: https://docs.civic.com/labs/private/x402-mcp
Create a payment-aware MCP server that charges for tool invocations. Define tools, set pricing, and connect with a payment-aware transport.
```typescript
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { makePaymentAwareServerTransport } from "@civic/x402-mcp";
// Create MCP server
const server = new McpServer({
name: "my-paid-server",
version: "1.0.0"
});
// Define your tools
server.tool(
"expensive-analysis",
{
description: "Perform complex data analysis",
inputSchema: {
type: "object",
properties: {
data: { type: "string" }
}
}
},
async (params) => {
// Your tool implementation
return { result: "Analysis complete" };
}
);
// Create payment-aware transport
const transport = makePaymentAwareServerTransport(
"0x1234...", // Your wallet address to receive payments
{
"expensive-analysis": "$0.010", // 1 cent per invocation
"another-tool": "$0.002" // 0.2 cents
}
);
// Connect with payment-aware transport
await server.connect(transport);
```
--------------------------------
### Manage Civic Toolkits
Source: https://docs.civic.com/civic/concepts/tips
Commands for creating, switching, and listing toolkits. Use 'show all' to see all toolkits and their associated tools.
```bash
"Create a new toolkit called 'marketing'"
```
```bash
"Switch to the development toolkit"
```
```bash
"Show all my toolkits and their tools"
```
```bash
"Filter out tools I haven't used in this session"
```
--------------------------------
### Install Civic Auth with uv
Source: https://docs.civic.com/auth
Install the Civic Auth Python package using uv. This is an alternative Python package installer for integrating Civic Auth into Python applications.
```bash
uv add civic-auth
```
--------------------------------
### List Installed Equipment
Source: https://docs.civic.com/civic/reference/servers/servicetitan
Retrieve a list of all equipment installed at customer locations.
```APIDOC
## list_installed_equipment
### Description
List equipment installed at customer locations.
### Method
GET
### Endpoint
/installed_equipment
### Parameters
#### Query Parameters
- **customer_id** (string) - Optional - Filter by customer ID.
- **location_id** (string) - Optional - Filter by location ID.
- **equipment_id** (string) - Optional - Filter by equipment ID.
```
--------------------------------
### Install Civic Auth Web3 SDK with bun
Source: https://docs.civic.com/auth
Install the Civic Auth Web3 SDK using bun. This SDK extends the base Civic Auth SDK with Web3 features.
```bash
bun add @civic/auth-web3
```
--------------------------------
### Create Installed Equipment
Source: https://docs.civic.com/civic/reference/servers/servicetitan
Record equipment that has been installed at a customer's location.
```APIDOC
## create_installed_equipment
### Description
Record equipment installed at a customer location.
### Method
POST
### Endpoint
/customers/{customer_id}/locations/{location_id}/installed_equipment
### Parameters
#### Path Parameters
- **customer_id** (string) - Required - The ID of the customer.
- **location_id** (string) - Required - The ID of the customer's location.
#### Request Body
- **equipment_id** (string) - Required - The ID of the equipment installed.
- **serial_number** (string) - Optional - The serial number of the equipment.
- **install_date** (string) - Optional - The date the equipment was installed (YYYY-MM-DD).
```
--------------------------------
### Install Civic Auth with Django using uv
Source: https://docs.civic.com/integration/python
Install the Civic Auth Python SDK with support for Django using the uv package manager.
```bash
uv add "civic-auth[django]"
```
--------------------------------
### Logout Example
Source: https://docs.civic.com/integration/vanillajs
Example of how to implement the logout functionality using the CivicAuth client.
```javascript
const logout = async () => {
await authClient?.logout();
// ... other logout logic
};
// To check authentication status before logout:
// const isAuthenticated = await authClient.isAuthenticated();
// To get user info before logout:
// const currentUser = await authClient.getCurrentUser();
```
--------------------------------
### Load Civic Setup Skill via Civic Chat
Source: https://docs.civic.com/civic/concepts/setup-skill
Instruct your AI agent to load the civic-setup skill using a natural language command.
```text
"Load the civic-setup skill"
```
--------------------------------
### Get Ad Performance
Source: https://docs.civic.com/civic/reference/servers/google-ads
Get ad performance metrics for the specified time period.
```APIDOC
## get_ad_performance
### Description
Get ad performance metrics for the specified time period.
### Method
APICall
### Endpoint
/google-ads/get_ad_performance
### Parameters
#### Query Parameters
- **account_id** (string) - Required - The ID of the Google Ads account.
- **start_date** (string) - Required - The start date for the performance metrics (YYYY-MM-DD).
- **end_date** (string) - Required - The end date for the performance metrics (YYYY-MM-DD).
- **ad_id** (string) - Optional - The ID of a specific ad to retrieve metrics for.
### Request Example
None
### Response
#### Success Response (200)
- **performance_metrics** (list) - A list of ad performance metrics.
### Response Example
{
"performance_metrics": [
{
"ad_id": "98765",
"headline": "Amazing Summer Deals!",
"impressions": 5000,
"clicks": 250,
"conversions": 25,
"cost": 120.50
}
]
}
```
--------------------------------
### Get Campaign Performance
Source: https://docs.civic.com/civic/reference/servers/google-ads
Gets campaign performance metrics for the specified time period.
```APIDOC
## get_campaign_performance
### Description
Get campaign performance metrics for the specified time period.
### Method
APICall
### Endpoint
/google-ads/get_campaign_performance
### Parameters
#### Query Parameters
- **account_id** (string) - Required - The ID of the Google Ads account.
- **start_date** (string) - Required - The start date for the performance metrics (YYYY-MM-DD).
- **end_date** (string) - Required - The end date for the performance metrics (YYYY-MM-DD).
- **campaign_id** (string) - Optional - The ID of a specific campaign to retrieve metrics for.
### Request Example
None
### Response
#### Success Response (200)
- **performance_metrics** (list) - A list of campaign performance metrics.
### Response Example
{
"performance_metrics": [
{
"campaign_id": "12345",
"campaign_name": "Summer Sale",
"impressions": 10000,
"clicks": 500,
"conversions": 50,
"cost": 250.75
}
]
}
```
--------------------------------
### Install Civic Auth Packages
Source: https://docs.civic.com/web3/embedded-wallets
Install the necessary Civic authentication packages for your Node.js project.
```bash
npm install @civic/auth @civic/auth-web3
```
--------------------------------
### Install DSPy and MCP Packages
Source: https://docs.civic.com/civic/recipes/dspy
Install the necessary Python packages for DSPy and MCP integration.
```bash
pip install dspy mcp python-dotenv
```
--------------------------------
### Basic Agent Setup with Civic Tools
Source: https://docs.civic.com/civic/recipes/openai-agents
Set up an OpenAI Agent to use Civic's hosted MCP tools. Ensure CIVIC_URL and CIVIC_TOKEN environment variables are set.
```typescript
import { Agent, hostedMcpTool, run } from '@openai/agents';
const agent = new Agent({
name: 'Civic Assistant',
model: 'gpt-4o-mini',
instructions: 'You are a helpful assistant with access to external tools through Civic.',
tools: [
hostedMcpTool({
serverLabel: 'civic',
serverUrl: process.env.CIVIC_URL!,
authorization: process.env.CIVIC_TOKEN!, // plain token string
}),
],
});
async function main() {
const result = await run(agent, 'List my GitHub repositories');
console.log(result.finalOutput); // the agent's final text response
}
main().catch(console.error);
```
--------------------------------
### Get Ad Creatives
Source: https://docs.civic.com/civic/reference/servers/google-ads
Get ad creative details including headlines, descriptions, and URLs.
```APIDOC
## get_ad_creatives
### Description
Get ad creative details including headlines, descriptions, and URLs.
### Method
APICall
### Endpoint
/google-ads/get_ad_creatives
### Parameters
#### Query Parameters
- **account_id** (string) - Required - The ID of the Google Ads account.
- **ad_id** (string) - Optional - The ID of a specific ad to retrieve creative details for.
### Request Example
None
### Response
#### Success Response (200)
- **ad_creatives** (list) - A list of ad creative details.
### Response Example
{
"ad_creatives": [
{
"ad_id": "98765",
"headline_1": "Amazing Summer Deals!",
"headline_2": "Limited Time Offer",
"description_1": "Get up to 50% off on selected items.",
"final_url": "https://www.example.com/summer-sale"
}
]
}
```
--------------------------------
### Vercel AI SDK Integration
Source: https://docs.civic.com/labs/private/mcp-hub
Example of how to initialize the MCP client using the Vercel AI SDK.
```javascript
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { getTokens } from "@civic/auth/nextjs";
const createMCPClient = async () => {
// Get access token
const { accessToken } = await getTokens();
if (!accessToken) {
throw new Error('No access token available. User needs to authenticate.');
}
// Create transport with authentication
const transport = new StreamableHTTPClientTransport(
'https://app.civic.com/hub/mcp',
{
requestInit: {
headers: {
Authorization: `Bearer ${accessToken}`,
'Content-Type': 'application/json'
}
}
}
);
// Initialize MCP client
const client = new Client({
name: 'my-app',
version: '1.0.0'
}, {
capabilities: {}
});
await client.connect(transport);
return client;
};
```
--------------------------------
### Install Civic Auth with Flask using uv
Source: https://docs.civic.com/integration/python
Install the Civic Auth Python SDK with support for Flask using the uv package manager.
```bash
uv add "civic-auth[flask]"
```
--------------------------------
### Connect to X402 MCP Demo Server
Source: https://docs.civic.com/labs/private/x402-mcp
Establish a connection to the hosted X402 MCP demo server for testing purposes. This requires a payment-aware client transport configured with the demo server URL and a wallet.
```javascript
const transport = makePaymentAwareClientTransport(
"https://x402-mcp.fly.dev/mcp",
wallet
);
```