1- # import asyncio
2- # from fastmcp import Client
3- #
4- # client = Client("myserver.py")
5- #
6- # async def call_tool(file: str, function: str)-> None:
7- # async with client:
8- # result = await client.call_tool("optimize_code", {"file": f"{file}", "function":f"{function}"})
9- # print(result)
10- #
11- # asyncio.run(call_tool("Ford","Mustang"))
12-
13-
141import anthropic
152from rich import print
16-
17- # Your server URL (replace with your actual URL)
183url = 'https://0de03d07f8b9.ngrok-free.app'
19-
204client = anthropic .Anthropic ()
21-
22- #file and fn names are hard coded for now
235response = client .beta .messages .create (
246 model = "claude-sonnet-4-20250514" ,
257 max_tokens = 1000 ,
2810 {
2911 "type" : "url" ,
3012 "url" : f"{ url } /mcp/" ,
31- "name" : "HelpfulAssistant " ,
13+ "name" : "Code Optimization Assistant " ,
3214 }
3315 ],
3416 extra_headers = {
3517 "anthropic-beta" : "mcp-client-2025-04-04"
3618 }
3719)
38-
39- print (response .content )
40-
41-
42- # import anthropic
43- # from rich import print
44- #
45- # # Your server URL (replace with your actual URL)
46- # url = 'https://0de03d07f8b9.ngrok-free.app'
47- #
48- # client = anthropic.Anthropic()
49- #
50- # response = client.beta.messages.create(
51- # model="claude-sonnet-4-20250514",
52- # max_tokens=1000,
53- # messages=[{"role": "user", "content": "Roll a few dice!"}],
54- # mcp_servers=[
55- # {
56- # "type": "url",
57- # "url": f"{url}/mcp/",
58- # "name": "Dice Roller",
59- # }
60- # ],
61- # extra_headers={
62- # "anthropic-beta": "mcp-client-2025-04-04"
63- # }
64- # )
65- #
66- # print(response.content)
20+ print (response .content )
0 commit comments