AI Agents as MCP Server: MUST KNOW client and server

Mervin PraisonAbout 5 min readMay 16, 2025Watch original
THE SUMMARYAI-generated

Key Concepts

  • Model Context Protocol (MCP)
  • MCP Client
  • MCP Server
  • Server Sent Events (SSE)
  • Standard Input/Output (stdio)
  • AI Agents
  • Tools (e.g., Internet search, Slack, Docker, GitHub)
  • Praise AI

Main Topics and Key Points

Introduction to MCP

  • MCP simplifies the integration of Large Language Models (LLMs) with various tools.
  • Without MCP, custom code is needed for each tool integration, which is tedious.
  • MCP provides a unified API for interacting with multiple tools.

MCP Architecture

  • The user asks a question to the LLM.
  • The LLM uses an MCP client to send the request to an MCP server.
  • The MCP server contains the tools.
  • The server executes the tools and returns the response to the LLM via the MCP client.
  • The LLM uses the response as context to generate the final answer for the user.

MCP Client vs. MCP Server

  • MCP Client: The interface used by the LLM to communicate with the MCP server. Examples include Cursor, Vinc, and Praise AI.
  • MCP Server: Hosts the tools and processes requests from the MCP client. Can be built manually or using tools like Praise AI.

SSE vs. stdio

  • stdio (Standard Input/Output):
    • Tools are executed locally via terminal commands (e.g., python app.py, npx).
    • Suitable for running scripts (Python, Bash) on your computer.
  • SSE (Server Sent Events):
    • Tools are hosted as a web application, either locally or on a public server.
    • Accessible via a URL (e.g., localhost:8000/SSE or a public web address).

Creating an MCP Server with Praise AI

  • Step 1: Install the Praise AI library: pip install praise-ai agents-mcp

  • Step 2: Export your OpenAI API key: export OPENAI_API_KEY=<your_api_key> (or use other LLMs like Ollama, LM Studio, Gemini, Anthropic, Claude)

  • Step 3: Create an app.py file with the following code:

    from praise_agents import Agent
    
    agent = Agent(name="Tweet Agent", description="Create a tweet based on the provided topic")
    agent.launch(port=8000, protocol="mcp")
    
  • Step 4: Run the server: python app.py

  • The server will be accessible at http://localhost:8000/SSE (or the specified port).

Integrating with MCP Clients

  • Cursor:
    • Go to Cursor settings and find the MCP section.
    • Add a new MCP server with the URL (e.g., http://localhost:8000) and path (/SSE).
    • Enable the server in the MCP servers list.
    • Ask a question in Cursor (e.g., "Tweet about AI"). Cursor will use the MCP server to generate the tweet.
  • Praise AI:
    • Use the Praise AI client to call any SSE MCP server.

    • Example code:

      from praise_agents import Agent, MCP
      
      agent = Agent(name="Tweet Verification Agent", llm="gpt-4-mini")
      mcp_tool = MCP(path="http://localhost:8000/SSE", name="tweet_agent")
      agent.add_tool(mcp_tool)
      
      response = agent.run("Start aai in healthcare")
      print(response)
      

Adding Multiple Tools

  • You can add multiple tools to your AI agent and publish them on your own server.
  • Tools can include internet search, private data access, or internal APIs.

Important Examples and Case Studies

  • Tweet Agent: A simple example of an AI agent that generates tweets based on a given topic.
  • Tweet Verification Agent: An agent that uses the Tweet Agent (hosted on an MCP server) to generate a tweet and then verifies it.

Step-by-Step Processes

  1. Creating an MCP Server:
    • Install Praise AI.
    • Export API key.
    • Create app.py with agent definition and agent.launch().
    • Run python app.py.
  2. Integrating with Cursor:
    • Go to Cursor settings.
    • Add MCP server with URL and path.
    • Enable the server.
    • Ask a question.
  3. Using Praise AI Client:
    • Import Agent and MCP from praise_agents.
    • Create an Agent instance.
    • Create an MCP tool instance with the server path.
    • Add the tool to the agent using agent.add_tool().
    • Run the agent using agent.run().

Key Arguments and Perspectives

  • MCP simplifies the integration of LLMs with tools, making AI applications more powerful.
  • Praise AI provides a convenient way to create and deploy MCP servers with minimal code.
  • SSE is suitable for web-based applications, while stdio is suitable for local scripts.

Notable Quotes

  • "Without MCP you need to write custom code to integrate your large language model with any of your tools this is tedious but after MCP this is simplified and you have only one unified API"
  • "MCP is like a bridge between your tools and large language model"

Technical Terms and Concepts

  • Model Context Protocol (MCP): A protocol for enabling LLMs to interact with external tools and data sources.
  • Server Sent Events (SSE): A server push technology enabling a server to send updates to a client over HTTP.
  • Standard Input/Output (stdio): A standard way for a program to receive input and send output, typically via the command line.
  • AI Agent: A software entity that can perceive its environment, make decisions, and take actions to achieve a goal.

Logical Connections

  • The video starts by explaining the problem of integrating LLMs with tools and how MCP solves it.
  • It then introduces the MCP architecture, including the client and server components.
  • The video differentiates between SSE and stdio, explaining when to use each.
  • It provides a step-by-step guide on creating an MCP server using Praise AI.
  • Finally, it demonstrates how to integrate the server with MCP clients like Cursor and Praise AI.

Data, Research Findings, or Statistics

  • No specific data, research findings, or statistics are mentioned in the transcript.

Synthesis/Conclusion

The video provides a practical guide to using Model Context Protocol (MCP) to enhance AI applications. It explains the benefits of MCP, the architecture involved, and the differences between SSE and stdio. The video then demonstrates how to create an MCP server using Praise AI with just three lines of code and how to integrate it with MCP clients like Cursor and Praise AI. The key takeaway is that MCP simplifies the integration of LLMs with tools, making it easier to build powerful AI applications.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.