Code Samples

Explore comprehensive code examples for building MCP integrations. These samples cover common integration patterns and can be used as starting points for your own custom integrations.

circle-info

Copy and Customize: These samples are designed to be copied into MCP Studio and customized for your specific needs. Replace placeholder values with your actual credentials and endpoints.

Sample Overview

Sample
Category
Description

Sales

Connect to CRM systems for customer data

Data

Query SQL databases securely

Integration

Connect to any REST API

Communication

Send messages to Slack channels

Documents

Parse and transform files

Research

Extract data from websites


CRM Integration

A complete CRM integration example that demonstrates fetching contacts, searching records, and creating new entries.

Use Cases

  • Retrieve customer information during conversations

  • Look up account details and history

  • Create new leads or contacts from chat

  • Update CRM records based on meeting outcomes

Python Code

Required Secrets

Secret
Description

CRM_BASE_URL

Base URL for your CRM API

CRM_API_KEY

API key for authentication


Database Query

A secure database query integration that allows read-only access to your PostgreSQL or MySQL database.

Use Cases

  • Query customer data during conversations

  • Generate reports on demand

  • Look up product information

  • Analyze historical data

Python Code

Required Secrets

Secret
Description
Example

DATABASE_URL

PostgreSQL connection string

postgresql://user:pass@host:5432/dbname

circle-exclamation

REST API Wrapper

A flexible REST API wrapper that can connect to any HTTP API.

Use Cases

  • Connect to internal APIs

  • Integrate third-party services

  • Access webhooks and endpoints

  • Retrieve data from any HTTP source

Python Code

Required Secrets

Secret
Description
Example

API_BASE_URL

Base URL for the API

https://api.example.com/v1

API_KEY

Authentication credential

sk_live_xxx...

AUTH_TYPE

Authentication type

bearer, api-key, or basic


Slack Notifications

Send messages and notifications to Slack channels.

Use Cases

  • Alert teams about important events

  • Share meeting summaries

  • Post workflow results

  • Send reminders and notifications

Python Code

Required Secrets

Secret
Description

SLACK_BOT_TOKEN

Slack Bot User OAuth Token (starts with xoxb-)

circle-info

Slack App Setup: Create a Slack App at api.slack.com/apps, add the chat:write, channels:read, and channels:history scopes, and install to your workspace.


Web Scraping

Extract data from web pages (use responsibly and respect robots.txt).

Use Cases

  • Research competitor websites

  • Extract product information

  • Gather public data

  • Monitor web content

Python Code

Required Secrets

This integration does not require secrets, but you may want to add:

Secret
Description
Optional

USER_AGENT

Custom User-Agent string

Yes

PROXY_URL

Proxy server for requests

Yes

circle-exclamation

Template Structure Reference

All MCP servers follow this basic structure:

Python Template

Key Elements

Element
Purpose

Server()

Creates the MCP server instance

@app.tool()

Decorator to register a tool

async def

Tools should be async for performance

Docstring

Describes the tool for the AI

TextContent

Standard return type for text responses

Environment variables

Secure way to access secrets

Next Steps

Goal
Documentation

Start building

Deploy your integration

Troubleshoot issues

Last updated

Was this helpful?