We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ContextualAI/contextual-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
server.py•758 B
from contextual import ContextualAI
from mcp.server.fastmcp import FastMCP
API_KEY = ""
AGENT = ""
# Create an MCP server
mcp = FastMCP("Contextual AI RAG Platform")
# Add query tool to interact with Contextual agent
@mcp.tool()
def query(prompt: str) -> str:
"""An enterprise search tool that can answer questions about a specific knowledge base"""
client = ContextualAI(
api_key=API_KEY, # This is the default and can be omitted
)
query_result = client.agents.query.create(
agent_id=AGENT,
messages=[{
"content": prompt,
"role": "user"
}]
)
return query_result.message.content
if __name__ == "__main__":
# Initialize and run the server
mcp.run(transport='stdio')