Skip to content

Commit dc83d07

Browse files
committed
Refactor documentation to improve clarity and structure. Updated import paths for MCPTool and enhanced examples for x402 payments and agent creation. Added detailed system prompts and improved agent capabilities with real-time web search and scraping tools. This enhances the usability and comprehensiveness of the guides for building AI agents.
1 parent 82b0894 commit dc83d07

File tree

5 files changed

+341
-436
lines changed

5 files changed

+341
-436
lines changed

docs/core-concepts/agents-detailed.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class SpoonMacroAnalysisAgent(SpoonReactMCP):
6161

6262
**Stdio-based Transport:**
6363
```python
64-
from spoon_ai.tools import MCPTool
64+
from spoon_ai.tools.mcp_tool import MCPTool
6565

6666
tavily_tool = MCPTool(
6767
name="tavily-search",

docs/core-concepts/mcp-protocol.md

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,29 @@ pip install spoon-ai
6464

6565
```python
6666
import asyncio
67-
from spoon_ai.mcp import MCPClient
67+
from spoon_ai.tools.mcp_tool import MCPTool
6868

69-
async def main():
70-
async with MCPClient.from_config({
69+
# Create an MCP tool that connects to an external MCP server
70+
mcp_tool = MCPTool(
71+
name="filesystem",
72+
description="Access filesystem via MCP",
73+
mcp_config={
7174
"command": "npx",
7275
"args": ["-y", "@anthropic/mcp-server-filesystem", "/tmp"]
73-
}) as client:
74-
tools = await client.list_tools()
75-
result = await client.call_tool("read_file", {"path": "/tmp/test.txt"})
76-
print(result)
76+
}
77+
)
78+
79+
async def main():
80+
# Load tool parameters from the MCP server
81+
await mcp_tool.ensure_parameters_loaded()
82+
83+
# List available tools
84+
tools = await mcp_tool.list_mcp_tools()
85+
print("Available tools:", [t.name for t in tools])
86+
87+
# Call a tool
88+
result = await mcp_tool.call_mcp_tool("read_file", path="/tmp/test.txt")
89+
print(result)
7790

7891
asyncio.run(main())
7992
```

docs/core-concepts/tools.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ from spoon_ai.tools import ToolManager
6969

7070
# Define a tool with JSON-schema parameters
7171
class GreetTool(BaseTool):
72-
name = "greet"
73-
description = "Greet someone by name"
74-
parameters = {
72+
name: str = "greet"
73+
description: str = "Greet someone by name"
74+
parameters: dict = {
7575
"type": "object",
7676
"properties": {"name": {"type": "string"}},
7777
"required": ["name"]
@@ -102,9 +102,9 @@ All tools inherit from `BaseTool` with three required attributes and one method:
102102
from spoon_ai.tools.base import BaseTool
103103

104104
class MyTool(BaseTool):
105-
name = "my_tool" # Unique identifier
106-
description = "What this tool does" # LLM reads this to decide when to use it
107-
parameters = { # JSON-schema for input validation
105+
name: str = "my_tool" # Unique identifier
106+
description: str = "What this tool does" # LLM reads this to decide when to use it
107+
parameters: dict = { # JSON-schema for input validation
108108
"type": "object",
109109
"properties": {
110110
"arg1": {"type": "string", "description": "First argument"},

docs/core-concepts/x402-payments.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,35 @@ sequenceDiagram
5656
## Quick Start
5757

5858
```bash
59-
pip install spoon-ai
59+
pip install spoon-ai x402
6060
export PRIVATE_KEY="your-wallet-private-key"
61+
export X402_RECEIVER_ADDRESS="0xYourReceiverWallet"
6162
```
6263

6364
```python
64-
from spoon_ai.agents import SpoonReactAI
65-
from spoon_ai.payments import x402_paywalled_request
66-
67-
# Agent auto-detects 402 and signs payments
68-
agent = SpoonReactAI(tools=[x402_paywalled_request])
69-
result = await agent.run("Fetch https://api.example.com/premium")
65+
import asyncio
66+
from spoon_ai.payments import X402PaymentService, X402PaymentRequest
67+
68+
# Initialize the payment service
69+
service = X402PaymentService()
70+
71+
async def main():
72+
# Create a payment request
73+
request = X402PaymentRequest(
74+
amount_usdc="0.01", # Amount in USDC
75+
resource="/premium-data",
76+
description="Access to premium data"
77+
)
78+
79+
# Sign and create payment receipt
80+
receipt = await service.sign_and_pay(request)
81+
print(f"Payment signed: {receipt}")
82+
83+
asyncio.run(main())
7084
```
7185

86+
> **Note:** For agent-based x402 payments, the agent handles 402 responses automatically when configured with payment capabilities. See the full examples in the x402 package for complete integration patterns.
87+
7288
---
7389

7490
## Components

0 commit comments

Comments
 (0)