Skip to main content

PostHog Agent Toolkit for LangChain and other AI frameworks

This project has been archived.

The maintainers of this project have marked this project as archived. No new releases are expected.

Project description

posthog-agent-toolkit

Tools to give agents access to your PostHog data, manage feature flags, create insights, and more.

This is a Python wrapper around the PostHog MCP (Model Context Protocol) server, providing easy integration with AI frameworks like LangChain.

Installation

pip install posthog-agent-toolkit

Quick Start

The toolkit provides integrations for popular AI frameworks:

Using with LangChain

from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
from posthog_agent_toolkit.integrations.langchain.toolkit import PostHogAgentToolkit

# Initialize the PostHog toolkit
toolkit = PostHogAgentToolkit(
    personal_api_key="your_posthog_personal_api_key",
    url="https://mcp.posthog.com/mcp"  # or your own, if you are self hosting the MCP server
)

# Get the tools
tools = await toolkit.get_tools()

# Initialize the LLM
llm = ChatOpenAI(model="gpt-5-mini")

# Create a prompt
prompt = ChatPromptTemplate.from_messages([
    ("system", "You are a data analyst with access to PostHog analytics"),
    ("human", "{input}"),
    MessagesPlaceholder("agent_scratchpad"),
])

# Create and run the agent
agent = create_tool_calling_agent(llm=llm, tools=tools, prompt=prompt)
executor = AgentExecutor(agent=agent, tools=tools)

result = await executor.ainvoke({
    "input": "Analyze our product usage by getting the top 5 most interesting insights and summarising the data from them."
})

→ See full LangChain example

Available Tools

For a list of all available tools, please see the docs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

posthog_agent_toolkit-0.1.2.tar.gz (82.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

posthog_agent_toolkit-0.1.2-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file posthog_agent_toolkit-0.1.2.tar.gz.

File metadata

  • Download URL: posthog_agent_toolkit-0.1.2.tar.gz
  • Upload date:
  • Size: 82.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for posthog_agent_toolkit-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8940b5a5d9a2d4c4947b0cd14dc391efa63eeb1b3793ebcd65e877830d6bc1bd
MD5 91aa1b0b22f029e6a3846f15dffdf41a
BLAKE2b-256 063b7f4f31aa3e7d1f0c5e6295613ee6981db0779b9b98d4c1160de8a5609f3d

See more details on using hashes here.

File details

Details for the file posthog_agent_toolkit-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for posthog_agent_toolkit-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5ee618f548f96868ca5c4e41c5fc54f4926c01e23f1b8d269d7afa9bbb922d5d
MD5 3f50ba038c7b01e9502a676679c28e33
BLAKE2b-256 bad39e3411b53999a2ce5fdb8b212295b7eea44e13f2b089f664ac7b2515c7d6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page