{"type":"mcp_server","name":"agentops","description":"AI Agent monitoring & cost tracking SDK. Benchmarking, LLM integration (Langchain, OpenAI, CrewAI & more). AgentOps.","category":"AI","language":"Python","stars":5730,"forks":427,"owner":"AgentOps-AI","github_url":"https://github.com/AgentOps-AI/agentops","homepage":"https://agentops.ai","setup":"## Setup\n\n### Installation\n\n```bash\npip install agentops\n```\n\n### Prerequisites\n\n*   Python 3.7+\n\n### Configuration\n\n1.  **Get an API Key:** Sign up for an AgentOps account and create a project to obtain your API key. You can find your API key in the [AgentOps dashboard](https://app.agentops.ai/settings/projects).\n\n### Quick Start\n\n1.  **Initialize AgentOps:** Add the following code to the beginning of your Python script (e.g., `main.py`, `__init__.py`), replacing `<INSERT YOUR API KEY HERE>` with your actual AgentOps API key:\n\n    ```python\n    import agentops\n\n    # Beginning of your program\n    agentops.init(\"<INSERT YOUR API KEY HERE>\")\n\n    # Your agent code here\n    ```\n\n2.  **End the Session:** Add the following code to the end of your Python script to properly close the AgentOps session:\n\n    ```python\n    # End of program\n    agentops.end_session('Success')\n    ```\n\n### Environment Variables (Optional)\n\nSome integrations, like CrewAI and AG2, rely on the `AGENTOPS_API_KEY` environment variable.  You can set this instead of passing the API key directly to `agentops.init()`.\n\n```bash\nexport AGENTOPS_API_KEY=\"YOUR_API_KEY\"\n```\n\nAlternatively, you can set it in your `.env` file:\n\n```\nAGENTOPS_API_KEY=\"YOUR_API_KEY\"\n```\n\nThen load the environment variables in your Python code:\n\n```python\nimport os\nimport agentops\nfrom dotenv import load_dotenv\n\nload_dotenv()  # Load environment variables from .env file\n\nagentops.init(os.getenv(\"AGENTOPS_API_KEY\"))\n\n# Your agent code here\n```","tools":"## Available Tools\n\nAgentOps provides a comprehensive suite of tools and features for building, evaluating, and monitoring AI agents, from prototype to production. These include:\n\n*   **Replay Analytics and Debugging:** Provides step-by-step agent execution graphs for in-depth analysis and debugging.\n*   **LLM Cost Management:** Tracks spending with LLM foundation model providers to help manage and optimize costs.\n*   **Agent Benchmarking:** Allows testing agents against 1,000+ evaluations to ensure performance and reliability.\n*   **Compliance and Security:** Detects common prompt injection and data exfiltration exploits to ensure agent security.\n*   **Framework Integrations:** Offers native integrations with popular frameworks like CrewAI, AG2 (AutoGen), Camel AI, LangChain, OpenAI Agents SDK, LlamaIndex, Cohere, Anthropic, Mistral, LiteLLM, Llama Stack and SwarmZero AI.\n\n**Key Features & Usage:**\n\n*   **Comprehensive Observability:** Track agent performance, user interactions, and API usage.\n*   **Real-Time Monitoring:** Gain instant insights with session replays, metrics, and live monitoring tools.\n*   **Cost Control:** Monitor and manage spending on LLM and API calls.\n*   **Failure Detection:** Quickly identify and respond to agent failures and multi-agent interaction issues.\n*   **Tool Usage Statistics:** Understand how agents utilize external tools with detailed analytics.\n*   **Session-Wide Metrics:** Gain a holistic view of agent sessions with comprehensive statistics.\n\n**Quick Start (Session Replays):**\n\n```python\nimport agentops\n\n# Beginning of your program (i.e. main.py, __init__.py)\nagentops.init( < INSERT YOUR API KEY HERE >)\n\n...\n\n# End of program\nagentops.end_session('Success')\n```\n\n**Developer Experience (Decorators):**\n\n```python\n# Create a session span (root for all other spans)\nfrom agentops.sdk.decorators import session\n\n@session\ndef my_workflow():\n    # Your session code here\n    return result\n```\n\n```python\n# Create an agent span for tracking agent operations\nfrom agentops.sdk.decorators import agent\n\n@agent\nclass MyAgent:\n    def __init__(self, name):\n        self.name = name\n        \n    # Agent methods here\n```\n\n```python\n# Create operation/task spans for tracking specific operations\nfrom agentops.sdk.decorators import operation, task\n\n@operation  # or @task\ndef process_data(data):\n    # Process the data\n    return result\n```\n\n```python\n# Create workflow spans for tracking multi-operation workflows\nfrom agentops.sdk.decorators import workflow\n\n@workflow\ndef my_workflow(data):\n    # Workflow implementation\n    return result\n```\n\n```python\n# Nest decorators for proper span hierarchy\nfrom agentops.sdk.decorators import session, agent, operation\n\n@agent\nclass MyAgent:\n    @operation\n    def nested_operation(self, message):\n        return f\"Processed: {message}\"\n        \n    @operation\n    def main_operation(self):\n        result = self.nested_operation(\"test message\")\n        return result\n\n@session\ndef my_session():\n    agent = MyAgent()\n    return agent.main_operation()\n```\n\n**Integrations:**\n\nAgentOps offers integrations with various frameworks and platforms:\n\n*   **OpenAI Agents SDK:** Build multi-agent systems with tools, handoffs, and guardrails.\n*   **CrewAI:** Build Crew agents with observability in just 2 lines of code.\n*   **AG2 (AutoGen):** Add full observability and monitoring to AG2 agents.\n*   **Camel AI:** Track and analyze CAMEL agents with full observability.\n*   **Langchain:** Seamlessly integrate with applications built using Langchain.\n*   **Cohere:** First class support for Cohere(>=5.4.0).\n*   **Anthropic:** Track agents built with the Anthropic Python SDK (>=0.32.0).\n*   **Mistral:** Track agents built with the Mistral Python SDK (>=0.32.0).\n*   **LiteLLM:** Support for LiteLLM(>=1.3.1), allowing you to call 100+ LLMs using the same Input/Output Format.\n*   **LlamaIndex:** Seamlessly integrate with applications built using LlamaIndex.\n*   **Llama Stack:** Support for Llama Stack Python Client(>=0.0.53), allowing you to monitor your Agentic applications.\n*   **SwarmZero AI:** Track and analyze SwarmZero agents with full observability.\n\n**Example Integrations:**\n\nSee the original documentation for integration examples with each framework.","faq":null,"created_at":"2023-08-15T23:26:23+00:00","updated_at":"2025-07-07T09:57:53+00:00","source_url":"https://model-context-protocol.com/servers/agentops","related_articles":[]}