Skip to main content

What is an MCP?

The Model Context Protocol (MCP) is an open protocol that enables seamless integration between Large Language Model (LLM) applications and external data sources and tools. By utilizing MCP, you can enhance your AI agents’ capabilities by connecting them to a wide range of tools developed by both companies and the community. This integration allows your agents to perform tasks that require external data access or specialized processing beyond their built-in functionalities. What do MCPs do?
  • Execute specific business logic or API calls
  • Interact with databases, file systems, or external services
  • Perform data processing, calculations, or transformations
  • Enable human-in-the-loop workflows with confirmation and input requirements
  • Provide caching and performance optimization capabilities
What are the parts of an MCP?
  • Server Definition: The MCP server class that specifies connection details
  • Command Configuration: The command and arguments to run the MCP server
  • Tool Integration: Automatic integration with Upsonic’s tool processing system
  • Error Handling: Robust error management for production reliability

Core Principles For MCPs

When integrating MCP tools into your AI agents, ensure you define these elements:
  • Clear Purpose: Each MCP should have a single, well-defined responsibility
  • Proper Configuration: All connection details must be correctly specified
  • Error Handling: Graceful failure handling with meaningful error messages
  • Security: Verify the security and reliability of the MCP tool, especially if it involves handling sensitive data

Defining MCP Server Classes

The MCP server class definition is the foundation of your MCP integration. Follow these guidelines:
  • Single Responsibility: Each MCP should do one thing well
  • Clear Configuration: Use descriptive class names and proper command/argument setup
  • Documentation: Write comprehensive docstrings that explain the MCP’s purpose and usage
Good MCP Definition:
Bad MCP Definition:

MCP Best Practices

Security Considerations

Validate and secure your MCP configurations:

Clear Documentation

Always provide comprehensive documentation:

Let’s Create MCP Tools for a Database Management Agent

In this example, we’ll create a comprehensive database management system using MCP tools and show how to combine them with regular Upsonic tools.
Need more advanced features? The MCP integration supports many powerful configuration options including:
  • Environment Variables: Pass environment variables to MCP servers for configuration
  • Custom Arguments: Specify custom command-line arguments for MCP servers
  • Error Handling: Robust error management for MCP server failures
  • Tool Combination: Seamlessly combine MCP tools with regular Upsonic tools
  • Structured Output: Use Pydantic models for structured MCP responses
  • Workflow Integration: Create complex workflows using multiple MCP tools
For detailed examples and advanced patterns, see our comprehensive MCP Concept Documentation.