Skip to content

Commit e9bc205

Browse files
committed
feat: super secret! changelog later
1 parent 6375709 commit e9bc205

File tree

9 files changed

+615
-65
lines changed

9 files changed

+615
-65
lines changed
125 KB
Loading
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# D:\AgentVault\docs\diagrams\architecture_diagram.py
2+
import os
3+
import platform
4+
import subprocess
5+
from diagrams import Diagram, Cluster, Edge
6+
# --- Option 1: Using different built-in icons ---
7+
from diagrams.programming.language import Python
8+
from diagrams.programming.framework import Fastapi # Correct icon for FastAPI
9+
from diagrams.onprem.database import Postgresql # Correct icon for the DB
10+
# Remove the incorrect API import: from diagrams.generic.network import API
11+
from diagrams.onprem.compute import Server # Correct module for generic Server
12+
from diagrams.generic.device import Computer # Generic User PC/Terminal
13+
from diagrams.generic.os import Ubuntu # Example generic OS/Node
14+
# --- Option 2: Required for Custom Icons ---
15+
from diagrams.custom import Custom # Import the Custom node type
16+
17+
# --- Define paths to your custom icons (replace with your actual filenames) ---
18+
# Assume icons are in a 'custom_icons' subfolder relative to this script
19+
script_dir = os.path.dirname(__file__)
20+
icon_folder = os.path.join(script_dir, "custom_icons")
21+
22+
# Define paths (use raw strings `r"..."` or os.path.join for reliability)
23+
# Replace 'placeholder_*.png' with your actual icon file names if you have them!
24+
library_icon = os.path.join(icon_folder, "placeholder_library.png")
25+
cli_icon = os.path.join(icon_folder, "placeholder_cli.png")
26+
sdk_icon = os.path.join(icon_folder, "placeholder_sdk.png")
27+
registry_icon = os.path.join(icon_folder, "placeholder_registry.png")
28+
agent_icon = os.path.join(icon_folder, "placeholder_agent.png")
29+
# --- End Custom Icon Paths ---
30+
31+
32+
# Give the diagram a filename (without extension)
33+
output_filename = "agentvault_high_level_architecture_v2"
34+
35+
# Define the diagram context
36+
with Diagram("AgentVault High-Level Architecture (Improved Icons)",
37+
show=False,
38+
filename=output_filename,
39+
outformat="png", # Or "svg"
40+
direction="LR"): # Layout direction: Left-to-Right
41+
42+
# --- Option 1 Example: Using a generic 'Computer' for the user ---
43+
user = Computer("Developer/User")
44+
45+
# --- Main AgentVault Components (using mix of built-in & custom) ---
46+
with Cluster("AgentVault Monorepo Components"):
47+
# --- Option 2 Example: Using Custom Icons ---
48+
# Check if icon file exists before using Custom, otherwise fallback or raise error
49+
if os.path.exists(cli_icon):
50+
cli = Custom("agentvault_cli", cli_icon)
51+
else:
52+
print(f"Warning: Custom icon not found at {cli_icon}, using default.")
53+
cli = Python("agentvault_cli") # Fallback
54+
55+
if os.path.exists(library_icon):
56+
library = Custom("agentvault_library", library_icon)
57+
else:
58+
print(f"Warning: Custom icon not found at {library_icon}, using default.")
59+
library = Python("agentvault_library") # Fallback
60+
61+
if os.path.exists(sdk_icon):
62+
server_sdk = Custom("agentvault_server_sdk", sdk_icon)
63+
else:
64+
print(f"Warning: Custom icon not found at {sdk_icon}, using default.")
65+
server_sdk = Python("agentvault_server_sdk") # Fallback
66+
67+
# testing_utils could remain Python or use a custom 'test' icon
68+
testing_utils = Python("agentvault_testing_utils")
69+
70+
# Dependencies
71+
cli >> Edge(label="uses") >> library
72+
server_sdk >> Edge(label="uses") >> library
73+
testing_utils >> Edge(label="tests") >> library
74+
testing_utils >> Edge(label="tests") >> server_sdk
75+
76+
# --- Registry Service (using mix of built-in & custom) ---
77+
with Cluster("AgentVault Registry Service"):
78+
# --- Option 1/2 Example: Choose Custom or FastAPI ---
79+
if os.path.exists(registry_icon):
80+
registry_api = Custom("Registry API", registry_icon)
81+
else:
82+
print(f"Warning: Custom icon not found at {registry_icon}, using FastAPI icon as fallback.")
83+
# Fallback to the accurate FastAPI icon if custom one is missing
84+
registry_api = Fastapi("Registry API")
85+
86+
# --- Using the specific Postgresql icon ---
87+
registry_db = Postgresql("Registry DB")
88+
89+
# UI could be Python, a generic 'Web' icon, or custom
90+
registry_ui = Python("Registry UI (Static/JS via FastAPI)")
91+
92+
registry_api >> Edge(label="stores/retrieves") >> registry_db
93+
registry_ui >> Edge(label="calls") >> registry_api
94+
95+
# --- Example Deployed A2A Agent (using Custom) ---
96+
with Cluster("Example A2A Agent Server"):
97+
# --- Option 2: Using Custom Agent Icon ---
98+
if os.path.exists(agent_icon):
99+
agent_server = Custom("A2A Agent", agent_icon)
100+
else:
101+
print(f"Warning: Custom icon not found at {agent_icon}, using generic Server.")
102+
agent_server = Server("A2A Agent") # Fallback to generic Server
103+
104+
# Agent logic could be Python or custom
105+
agent_logic = Python("Agent Logic")
106+
107+
agent_server >> Edge(label="runs") >> agent_logic # Changed label slightly
108+
agent_logic >> Edge(label="uses") >> server_sdk
109+
110+
# Define the main interaction flows
111+
user >> Edge(label="runs tasks/config") >> cli
112+
cli >> Edge(label="queries") >> registry_api
113+
cli >> Edge(label="A2A Calls") >> agent_server
114+
registry_api >> Edge(label="validates models") >> library # More specific label
115+
user >> Edge(label="browses/registers") >> registry_ui
116+
117+
118+
print(f"Diagram generated: {output_filename}.png (or specified outformat)")
119+
# Add a reminder about custom icons if placeholders were used
120+
if "placeholder_" in open(__file__).read():
121+
print("\nReminder: This script uses placeholder paths for custom icons.")
122+
print(f"Please add your actual .png/.jpg icon files to the '{icon_folder}' directory")
123+
print("and update the icon paths (e.g., library_icon, cli_icon) in this script.")

docs/index.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ A live instance of the AgentVault Registry API and its associated Web UI is host
2626

2727
The AgentVault monorepo contains the following key components:
2828

29-
* **`agentvault_library`**: ([Developer Guide](developer_guide/library.md)) Core Python client library for interacting with A2A agents, managing keys, and handling protocols (A2A, MCP).
29+
* **`agentvault_library`**: ([Developer Guide](developer_guide/library.md)) Core Python client library for interacting with A2A agents, managing keys, and handling protocols (A2A, [MCP](mcp.md)).
3030
* **`agentvault_cli`**: ([User Guide](user_guide/cli.md)) Command-line interface for users and developers to manage credentials, discover agents, and run tasks.
3131
* **`agentvault_registry`**: ([Developer Guide](developer_guide/registry.md)) Backend API server (FastAPI) acting as the central discovery point for registered agents. Also serves a **Web UI** for public discovery (`/ui`) and developer management (`/ui/developer`). *(Live instance available above)*
3232
* **`agentvault_server_sdk`**: ([Developer Guide](developer_guide/server_sdk.md)) Python SDK to help developers build A2A-compliant agent servers easily, integrating with frameworks like FastAPI. Includes packaging tools.
@@ -35,6 +35,11 @@ The AgentVault monorepo contains the following key components:
3535
* **`automation_scripts/`**: Scripts to automate common workflows like agent packaging and deployment.
3636
* **`docs/`**: Source files for this documentation website (built with MkDocs).
3737

38+
## Key Protocols
39+
40+
* **[Agent-to-Agent (A2A) Profile v0.2](a2a_profile_v0.2.md):** Defines the core communication patterns, task lifecycle, and event streaming via JSON-RPC and SSE.
41+
* **[Model Context Protocol (MCP) Profile (Concept)](mcp.md):** Specifies how to embed richer context (like tool requests or user profiles) within standard A2A messages.
42+
3843
## Installation
3944

4045
Please refer to the [Installation Guide](installation.md). For development setup, see the [Contributing Guide](CONTRIBUTING.md).
@@ -45,4 +50,4 @@ Contributions are welcome! Please see the [Contributing Guide](CONTRIBUTING.md)
4550

4651
## License
4752

48-
AgentVault is licensed under the Apache License, Version 2.0. See the [LICENSE](../LICENSE) file in the project root for details.
53+
AgentVault is licensed under the Apache License, Version 2.0. See the [LICENSE](../LICENSE) file in the project root for details.

docs/mcp.md

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
```markdown
2+
# Model Context Protocol (MCP) - AgentVault Profile
3+
4+
## Introduction
5+
6+
The AgentVault Agent-to-Agent (A2A) protocol defines the core mechanisms for secure communication, task management, and event streaming between agents. However, many complex agent interactions require more than just the primary message content. Agents often need additional **context** to perform their tasks effectively. This could include:
7+
8+
* User profile information
9+
* Relevant snippets from previous interactions
10+
* Metadata about the environment
11+
* References to external files or data artifacts
12+
* Schema definitions for expected inputs/outputs
13+
* Tool descriptions and schemas
14+
15+
The **Model Context Protocol (MCP)** is designed to be the standardized way to provide this richer context within the AgentVault ecosystem. It is *not* a separate transport protocol but rather a defined structure for embedding context *within* standard A2A messages.
16+
17+
## Current Status
18+
19+
**Evolving Specification:** It's important to note that the formal MCP specification is still evolving within the broader AI agent community. The implementation within AgentVault currently represents a **basic, conceptual profile** based on common needs observed during development.
20+
21+
**Implementation:** The core `agentvault` library provides utilities (`agentvault.mcp_utils`) for formatting and validating a basic MCP structure, and the `agentvault-server-sdk` provides helpers for extracting it on the agent side. Future versions of AgentVault will align with and potentially contribute to more formalized MCP standards as they emerge.
22+
23+
## Transport Mechanism
24+
25+
MCP context is transported within the `metadata` field of standard A2A `Message` objects (defined in `agentvault.models`). Specifically, the formatted MCP payload is expected under the key `"mcp_context"`.
26+
27+
```json
28+
{
29+
"role": "user",
30+
"parts": [
31+
{ "type": "text", "content": "Refactor the attached Python script." }
32+
// Potentially other parts like FilePart referencing the script
33+
],
34+
"metadata": {
35+
"timestamp": "...",
36+
"client_request_id": "...",
37+
// MCP context is embedded here:
38+
"mcp_context": {
39+
// ... MCP payload structure ...
40+
}
41+
}
42+
}
43+
```
44+
45+
## Conceptual Structure (Based on Current Implementation)
46+
47+
The current implementation in `agentvault.mcp_utils` defines a basic structure using Pydantic models as placeholders.
48+
49+
1. **`MCPContext` (Root Object):**
50+
* The top-level container for the context.
51+
* Currently defined with a single primary field:
52+
* `items`: A dictionary where keys are unique identifiers/names for context items, and values are `MCPItem` objects.
53+
54+
2. **`MCPItem` (Individual Context Piece):**
55+
* Represents a single piece of contextual information.
56+
* Fields:
57+
* `id` (Optional `str`): A unique identifier for this specific item within the context payload.
58+
* `mediaType` (Optional `str`): The MIME type of the `content` if applicable (e.g., "text/plain", "application/json", "text/csv").
59+
* `content` (Optional `Any`): The actual contextual data itself (e.g., a string, dictionary, list). Used for embedding smaller pieces of context directly.
60+
* `ref` (Optional `str`): A reference (e.g., a URL, artifact ID) pointing to external context information, often used for larger data.
61+
* `metadata` (Optional `Dict[str, Any]`): Additional key-value metadata specific to this context item.
62+
63+
**Example `mcp_context` Payload:**
64+
65+
```json
66+
"mcp_context": {
67+
"items": {
68+
"user_profile": {
69+
"mediaType": "application/json",
70+
"content": {
71+
"user_id": "usr_123",
72+
"preferences": {"theme": "dark"},
73+
"permissions": ["read", "write"]
74+
},
75+
"metadata": {"source": "internal_db"}
76+
},
77+
"target_document": {
78+
"mediaType": "application/pdf",
79+
"ref": "s3://my-bucket/documents/report.pdf",
80+
"metadata": {"version": "1.2"}
81+
},
82+
"system_instruction_override": {
83+
"mediaType": "text/plain",
84+
"content": "Focus specifically on the financial results section.",
85+
"id": "instr-001"
86+
}
87+
}
88+
}
89+
```
90+
91+
## Client-Side Usage (AgentVault Library)
92+
93+
The `agentvault.client.AgentVaultClient` provides optional parameters in its `initiate_task` and `send_message` methods to include MCP context:
94+
95+
```python
96+
# Example using agentvault library
97+
from agentvault import AgentVaultClient, KeyManager, Message, TextPart, agent_card_utils
98+
from agentvault.models import AgentCard # Assuming AgentCard is available
99+
100+
# Assume agent_card, key_manager are loaded/initialized
101+
client = AgentVaultClient()
102+
initial_message = Message(role="user", parts=[TextPart(content="Analyze this data.")])
103+
104+
# Define the context payload
105+
mcp_payload = {
106+
"items": {
107+
"data_reference": {
108+
"ref": "https://data.example.com/dataset.csv",
109+
"mediaType": "text/csv"
110+
},
111+
"analysis_params": {
112+
"content": {"mode": "deep", "output_format": "json"},
113+
"mediaType": "application/json"
114+
}
115+
}
116+
}
117+
118+
try:
119+
# Pass the payload to initiate_task
120+
task_id = await client.initiate_task(
121+
agent_card=agent_card,
122+
initial_message=initial_message,
123+
key_manager=key_manager,
124+
mcp_context=mcp_payload # Pass the context dictionary here
125+
)
126+
print(f"Task initiated with MCP context, ID: {task_id}")
127+
128+
# ... handle subsequent events ...
129+
130+
except Exception as e:
131+
print(f"Error: {e}")
132+
133+
```
134+
135+
The client library uses `agentvault.mcp_utils.format_mcp_context` internally to perform basic validation against the placeholder Pydantic models and embed the formatted context into `message.metadata["mcp_context"]` before sending the request.
136+
137+
## Server-Side Usage (AgentVault Server SDK)
138+
139+
Agents built using the `agentvault-server-sdk` can easily extract the MCP context from incoming messages using the provided utility function:
140+
141+
```python
142+
# Example within an AgentVault SDK Agent method
143+
from agentvault_server_sdk import BaseA2AAgent
144+
from agentvault_server_sdk.mcp_utils import get_mcp_context
145+
from agentvault.models import Message # Assuming Message is available
146+
147+
class MyAgent(BaseA2AAgent):
148+
# ... other methods ...
149+
150+
async def handle_task_send(self, task_id: Optional[str], message: Message) -> str:
151+
# Extract MCP context
152+
mcp_data = get_mcp_context(message)
153+
154+
if mcp_data:
155+
print(f"Received MCP context for task {task_id or 'new'}: {mcp_data}")
156+
# Access specific items
157+
user_profile = mcp_data.get("items", {}).get("user_profile")
158+
if user_profile and user_profile.get("content"):
159+
user_id = user_profile["content"].get("user_id")
160+
print(f"User ID from MCP: {user_id}")
161+
# ... process context items ...
162+
else:
163+
print(f"No valid MCP context found in message for task {task_id or 'new'}.")
164+
165+
# ... rest of task handling logic ...
166+
new_task_id = f"task-{uuid.uuid4().hex[:6]}"
167+
# ... store task state, start background work etc ...
168+
return new_task_id
169+
170+
```
171+
172+
The `get_mcp_context` function safely checks for the presence and type of `message.metadata` and the `"mcp_context"` key, returning the dictionary if found, or `None` otherwise.
173+
174+
## Future Directions
175+
176+
As MCP standards solidify, AgentVault plans to:
177+
178+
* Adopt or contribute to official schema definitions.
179+
* Enhance validation logic in `mcp_utils`.
180+
* Potentially provide more structured ways to interact with specific MCP item types within the SDK.
181+
182+
The current implementation provides a flexible placeholder mechanism for passing structured context alongside core A2A messages.
183+
```

mkdocs.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@ theme:
3333
plugins:
3434
- search # Enable search plugin
3535

36-
# --- MODIFIED: Added Vision and Use Cases (placeholder) to Nav ---
3736
nav:
3837
- Home: index.md
39-
- Vision: vision.md # Added Vision page prominently
38+
- Vision: vision.md
4039
- Introduction:
4140
- Concepts: concepts.md
4241
- Architecture: architecture.md
43-
- Use Cases: use_cases.md # Added Use Cases page link
42+
- Use Cases: use_cases.md
4443
- Installation: installation.md
4544
- Examples:
4645
- Overview: examples.md
@@ -58,6 +57,9 @@ nav:
5857
- Testing Utilities (`agentvault-testing-utils`): developer_guide/testing.md
5958
- Protocols:
6059
- A2A Profile v0.2: a2a_profile_v0.2.md
60+
# --- ADDED MCP LINK ---
61+
- MCP Profile (Concept): mcp.md
62+
# --- END ADDED ---
6163
- TEE Profile: tee_profile.md
6264
- Project & Policies:
6365
- Contributing: CONTRIBUTING.md
@@ -68,7 +70,6 @@ nav:
6870
- Terms of Service: TERMS_OF_SERVICE.md
6971
- Privacy Policy: privacy_policy.md
7072
- Roadmap: ROADMAP.md
71-
# --- END MODIFIED ---
7273

7374
# Source directory for markdown files
7475
docs_dir: 'docs'
@@ -94,4 +95,4 @@ markdown_extensions:
9495
- md_in_html # Allows markdown processing inside HTML blocks
9596

9697
# Copyright notice (optional)
97-
# copyright: Copyright © 2025 AgentVault Contributors
98+
# copyright: Copyright © 2025 AgentVault Contributors

0 commit comments

Comments
 (0)