77# tools = from_mcp_server(MCPHttpParams(url="https://remote.mcpservers.org/fetch/mcp"))
88# tools = from_mcp_server(MCPHttpParams(url="https://mcp.paypal.com/sse"))
99
10+
1011def get_paypal_auth ():
1112 response = requests .post ( # paypal only atm
1213 "https://api-m.sandbox.paypal.com/v1/oauth2/token" ,
@@ -23,54 +24,32 @@ def get_paypal_auth():
2324
2425paypal_headers = {"Authorization" : f"Bearer { get_paypal_auth ()} " }
2526
26- async def langchain ():
27- from langchain .chat_models import init_chat_model
28- from langchain_mcp_adapters .client import MultiServerMCPClient
29- client = MultiServerMCPClient (
30- {
31- "fetch" : { # no auth needed
32- "transport" : "streamable_http" ,
33- "url" : "https://remote.mcpservers.org/fetch/mcp" ,
34- },
35- "paypal" : { # sse + oauth2.0
36- "transport" : "sse" ,
37- "url" : "https://mcp.paypal.com/sse" ,
38- "headers" : paypal_headers ,
39- },
40- }
41- )
42- mcp_tools = await client .get_tools ()
43- # print(mcp_tools)
44- model_gpt = init_chat_model ("gpt-4o-mini" , model_provider = "openai" ).bind_tools (tools = mcp_tools )
45- # message = "Who is Aryan Ballani? look up aryanballani.github.io"
46- message = "List the tools you available to you related to paypal"
47- response = model_gpt .invoke (message )
48- print (response .content )
27+ # #paragon
28+ # import requestcompletion as rc
29+ # paypal_headers = {"Authorization": f"Bearer {rc.oauth("paypal")}"}
4930
5031def request_completion ():
5132 import requestcompletion as rc
5233 from requestcompletion .nodes .library import from_mcp_server , tool_call_llm
5334 from requestcompletion .rc_mcp import MCPHttpParams
5435
55- fetch_tools = from_mcp_server (MCPHttpParams (url = "https://remote.mcpservers.org/fetch/mcp" ))
56- paypal_tools = from_mcp_server (MCPHttpParams (url = "https://mcp.paypal.com/sse" , headers = paypal_headers ))
36+ fetch_tools = from_mcp_server (MCPHttpParams (url = "https://remote.mcpservers.org/fetch/mcp" )). tools
37+ paypal_tools = from_mcp_server (MCPHttpParams (url = "https://mcp.paypal.com/sse" , headers = paypal_headers )). tools
5738 tools = fetch_tools + paypal_tools
58-
5939 agent = tool_call_llm (
6040 connected_nodes = {* tools },
6141 system_message = """You are a master paypal agent. You love creating beautiful
6242 and well-structured paypal pages and make sure that everything is correctly formatted.""" ,
6343 model = rc .llm .OpenAILLM ("gpt-4o" ),
64- )
44+ )
6545
6646 user_prompt = """List the tools you available to you related to paypal"""
67- mh = rc .llm .MessageHistory (rc .llm .UserMessage (user_prompt ))
47+ mh = rc .llm .MessageHistory ([ rc .llm .UserMessage (user_prompt )] )
6848
6949 with rc .Runner (rc .ExecutorConfig (logging_setting = "VERBOSE" )) as run :
7050 result = run .run_sync (agent , mh )
7151 print (result .answer .content )
7252
7353# Run the functions
74- # asyncio.run(langchain())
7554# asyncio.run(request_completion())
7655request_completion ()
0 commit comments