8/8
Real-World MCP Applications Β· Page 1 of 1

MCP in Practice

Real-World MCP Applications

Database Server

MCP server for database access:

class DatabaseMCPServer(MCPServer):
    def __init__(self, connection_string):
        self.db = connect(connection_string)
    
    @tool()
    def query(self, sql: str) -> dict:
        "Execute SQL query (read-only)"
        return self.db.execute(sql)
    
    @tool()
    def describe_table(self, table: str) -> dict:
        "Get table schema"
        return self.db.describe(table)

# LLM can now query any database!
llm.chat("Show me top users by revenue")
# LLM calls: describe_table, query
# Returns: Results with proper SQL

Search Server

Multi-source search:

class SearchMCPServer(MCPServer):
    @tool()
    def web_search(self, query: str):
        "Search the web"
        return google_search(query)
    
    @tool()
    def code_search(self, query: str):
        "Search GitHub"
        return github_search(query)
    
    @tool()
    def academic_search(self, query: str):
        "Search academic papers"
        return arxiv_search(query)

# Single interface to all search sources!

Integration Server

Connect multiple APIs:

class IntegrationServer(MCPServer):
    @tool()
    def slack_send_message(self, channel: str, text: str):
        "Send Slack message"
        return slack.send(channel, text)
    
    @tool()
    def github_create_issue(self, repo: str, title: str):
        "Create GitHub issue"
        return github.create_issue(repo, title)
    
    @tool()
    def salesforce_update_lead(self, lead_id: str, data: dict):
        "Update Salesforce lead"
        return salesforce.update(lead_id, data)

# Agents can orchestrate across tools!

Custom Logic Server

Domain-specific business logic:

class BusinessLogicServer(MCPServer):
    @tool()
    def calculate_invoice(self, items: list):
        "Calculate invoice with tax, discounts"
        subtotal = sum(i["price"] for i in items)
        discount = subtotal * 0.1 if subtotal > 1000 else 0
        tax = (subtotal - discount) * 0.08
        total = subtotal - discount + tax
        return {
            "subtotal": subtotal,
            "discount": discount,
            "tax": tax,
            "total": total
        }
    
    @tool()
    def check_inventory(self, product: str) -> bool:
        "Check if in stock"
        return inventory.get(product, 0) > 0

Why MCP Works

Before: Build integration for each LLM/framework
After: Build MCP server once, use everywhere

Database Server works with:
- Claude
- GPT-4
- LangChain agents
- Custom applications
- Future LLMs

Write once, deploy everywhere!
Done
main.py
Loading...
OUTPUT
β–ΆClick "Run Code" to execute…