mirror of
https://github.com/stripe/ai.git
synced 2026-09-14 18:39:59 +08:00
36 lines
942 B
Python
36 lines
942 B
Python
import asyncio
|
|
import os
|
|
|
|
from dotenv import load_dotenv
|
|
load_dotenv()
|
|
|
|
from agents import Agent, Runner, WebSearchTool
|
|
from stripe_agent_toolkit.openai.toolkit import create_stripe_agent_toolkit
|
|
|
|
|
|
async def main():
|
|
# Initialize the Stripe toolkit (connects to MCP server)
|
|
stripe_agent_toolkit = await create_stripe_agent_toolkit(
|
|
secret_key=os.getenv("STRIPE_SECRET_KEY"),
|
|
)
|
|
|
|
try:
|
|
research_agent = Agent(
|
|
name="Research Agent",
|
|
instructions="You are an expert at research.",
|
|
tools=[WebSearchTool(), *stripe_agent_toolkit.get_tools()],
|
|
)
|
|
|
|
result = await Runner.run(
|
|
research_agent,
|
|
"search the web for 'global gdp' and give me the latest data.",
|
|
)
|
|
print(result.final_output)
|
|
finally:
|
|
# Clean up MCP connection
|
|
await stripe_agent_toolkit.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|