Exposing an AI Agent as an MCP server > Overview > Step 1. Create the MCP server configuration
  

Step 1. Create the MCP server configuration

You can create an MCP server configuration in a number of ways. In this example, we’ll use FastMCP to create a server configuration from scratch.
    1Create a server.py file that instantiates a FastMCP server.
    For example, add the following code:
    from mcp.server.fastmcp import FastMCP
    mcp = FastMCP("My API Server")
    2Define at least one MCP tool.
    The following sample tool takes the prompt and conversation ID as parameters, posts them through the REST API, and returns the AI agent's response if successful:
    @mcp.tool()
    def interact_with_agent(prompt: str, conversationID: str) -> str:

    """Uses the information in the prompt to interact with the AI agent."""

    # Define authentication
    import requests
    headers = {
    "Authorization": "<authorization string>"
    }

    # Define the API request
    url = "<Endpoint URL from AI Agent Engineering>"

    #Create the data object required by the API
    data = {
    "prompt": prompt,
    "conversationID": conversationID
    }

    # Post the API request
    import sys
    response = requests.post(url, json=data, headers=headers)

    # Handle the response to extract the required payload
    if response.status_code == 200:
    return str(response.json())

    #Add error handling
    return None
    For more information about creating tools with FastMCP, see "Tools" in the FastMCP documentation.