AGENTCHAIN is a blockchain-based platform designed to facilitate a transparent, verifiable, and monetizable ecosystem for AI capabilities. It implements the Model Context Protocol (MCP), allowing various AI-related functionalities (Tools, Prompts, Plugins, Memory Services) to be registered, discovered, invoked, and audited on-chain. Each interaction with an MCP capability results in a blockchain transaction, creating an immutable record and potentially involving NRN token fees.
- Model Context Protocol (MCP): A set of standards for defining, discovering, and interacting with AI capabilities. AGENTCHAIN serves as a decentralized backend for MCP.
- Capabilities: These are the core building blocks of the MCP ecosystem on AGENTCHAIN. They include:
- Resources: Expose structured or dynamic content. This includes:
- Plugins: Developer-uploaded executables (e.g., Go
.so, Wasm) hosted by devs, discovered on-chain, downloaded, and run by clients. - Datasets: References to datasets with on-chain metadata and hashes.
- Model Artifacts: References to AI model files.
- APIs: Descriptors for external APIs.
- Plugins: Developer-uploaded executables (e.g., Go
- Tools: Executable actions defined with JSON schemas for input and output. Can be backed by plugins or external APIs.
- Prompts: Reusable, parameterized prompt templates for LLMs.
- Memory Services: Capabilities providing persistent, graph-like memory stores.
- Resources: Expose structured or dynamic content. This includes:
- Capability Descriptors: Metadata structures (e.g.,
ResourceDescriptor,ToolDescriptor) registered on the blockchain.ResourceDescriptor(for plugins/resources): Defines properties, owner, NRN gas fee. Includes aContentHashof the capability package. Its nestedSchemafield contains aSummary,LocationHintsfor package download, and paths to theManifestFileandExecutableFilewithin the package.- Other descriptors like
ToolDescriptor,PromptDescriptordefine their respective capability types.
- ContextRecord: An on-chain record logged for every significant MCP interaction (e.g., capability invocation, registration). It details what happened, when, by whom, and with what references (hashes, fees), forming an immutable audit trail.
- NRN Tokens: The native utility token of AGENTCHAIN, used for:
- Paying gas fees for registering and invoking MCP capabilities.
- Compensating capability owners (e.g., plugin developers).
- AGENTCHAIN Node: The core blockchain dev software that maintains the ledger, processes MCP transactions, and exposes an API.
- Wallet Server: A service that helps users create, sign, and submit MCP transactions to the AGENTCHAIN network.
- agent Client (Inference Engine): An application that interacts with AGENTCHAIN to discover, download (for plugins), execute, and log the usage of MCP capabilities.
-
Capability Registration:
- Developers register their capabilities (e.g., a new Plugin) by submitting an
MCPRegisterCapabilityTransactionto the AGENTCHAIN. - This transaction contains the serialized
CapabilityDescriptor(e.g.,ResourceDescriptorfor a plugin, including itsContentHash,LocationHints, andGasFeeNRN). - The
ResourceDescriptoris stored on-chain.
- Developers register their capabilities (e.g., a new Plugin) by submitting an
-
Capability Discovery:
- agent Clients query the AGENTCHAIN API (e.g.,
GET /mcp/capabilities?resourceType=PLUGIN) to find available capabilities.
- agent Clients query the AGENTCHAIN API (e.g.,
-
Capability Invocation & Plugin Execution:
- For Plugins:
- The agent Client downloads the plugin binary from a
LocationHintprovided in itsResourceDescriptor. - The client verifies the downloaded package's integrity using the on-chain
ContentHash. - The client executes the plugin locally (ideally in a sandboxed environment).
- The agent Client downloads the plugin binary from a
- For other capabilities (Tools, Prompts): The client prepares input according to the capability's schema.
- Logging Usage: The client (or wallet server on its behalf) creates an
MCPInvokeCapabilityTransaction.- This transaction includes a
ContextRecorddetailing the invocation (e.g.,CapabilityID,InteractionType,Initiator,InputHash,OutputHash). - It also includes the NRN
Feespecified by the capability. - This transaction is submitted to the AGENTCHAIN, creating an on-chain audit log.
- This transaction includes a
- For Plugins:
- Decentralized Registry: Immutable, transparent record of all registered MCP capabilities.
- Verifiable Audit Trail:
ContextRecords provide on-chain proof of all capability interactions. - Monetization: Capability owners earn NRN tokens for usage.
- Plugin Ecosystem: Allows developers to offer executable functionalities (plugins) that clients can securely download and run.
- Standardized Interaction: MCP provides a common way to interact with diverse AI capabilities.
The ContextRecord is central to AGENTCHAIN's value, providing an on-chain, verifiable log. Here are some examples:
-
Using a Registered Tool:
- An AI agent uses a "PriceOracleTool." A
ContextRecordis logged withInteractionType: "TOOL_INVOCATION",CapabilityIDof the tool,Initiator(agent's address),InputHash,OutputHash, and the NRNFeepaid. - Querying:
GET /mcp/capability/{tool_id}/invocationsto see all tool uses.
- An AI agent uses a "PriceOracleTool." A
-
Utilizing a Registered Prompt:
- An application uses a "StoryGeneratorPrompt." A
ContextRecordlogsInteractionType: "PROMPT_USAGE",CapabilityID,Initiator, andInputHash(of prompt parameters). - Querying:
GET /mcp/context/{tx_id}to see specific prompt parameters used.
- An application uses a "StoryGeneratorPrompt." A
-
Executing a Registered Plugin:
- A agent Client runs a "ModValidatorPlugin." A
ContextRecordlogsInteractionType: "PLUGIN_EXECUTION",CapabilityID,Initiator,InputHash(of the mod file), andOutputHash(of the validation report). - Querying:
GET /mcp/contexts?initiator={client_address}&capabilityId={plugin_id}for a client's usage history of a plugin.
- A agent Client runs a "ModValidatorPlugin." A
-
Interacting with a Memory Service:
- An AI writes to a "UserPreferencesMemory" service. A
ContextRecordlogsInteractionType: "MEMORY_WRITE",CapabilityID,Initiator, andInputHash(of the preference data). - Querying:
GET /mcp/contexts?capabilityId={memory_id}&interactionType=MEMORY_WRITEto audit memory writes.
- An AI writes to a "UserPreferencesMemory" service. A
-
Logging a Sampling Event (Server-Side):
- An MCP server initiates a client-side LLM task. A
ContextRecordlogsInteractionType: "SAMPLING_REQUEST_SENT",Initiator(server's address), andInputHash(of the task).
- An MCP server initiates a client-side LLM task. A
-
Auditing Capability Registrations:
- (Optional but recommended) When a new capability is registered via
MCPRegisterCapabilityTransaction, aContextRecordwithInteractionType: "CAPABILITY_REGISTRATION"can also be logged, providing a unified feed of all MCP events. - Querying:
GET /mcp/contexts?interactionType=CAPABILITY_REGISTRATIONfor a list of all new capabilities.
- (Optional but recommended) When a new capability is registered via
These records are crucial for billing, provenance, debugging, and analytics within the AGENTCHAIN MCP ecosystem.
-
LevelDB (Primary):
- Stores the core blockchain data (blocks, transactions).
- Stores an indexed view of MCP data extracted from the blockchain:
- Serialized
CapabilityDescriptors (e.g.,ResourceDescriptor,ToolDescriptor) viamcp:capability:<id> -> descriptor_json. - Serialized
ContextRecords (e.g.,mcp:context:<tx_id> -> context_record_json). - NRN token account balances.
- Serialized
- This indexed view powers the API query endpoints for basic lookups.
-
Off-Chain Storage:
- Actual plugin binaries, large datasets, and model artifacts are stored off-chain (e.g., hosted by devs, on IPFS, or other web services).
- The on-chain
ResourceDescriptorcontains:- A
ContentHashfor integrity verification of the downloaded package. Schema.LocationHints(URIs) for retrieving the package.
- A
AGENTCHAIN exposes HTTP APIs through its nodes and wallet server.
- Generic Transaction Submission:
POST /transaction: Receives fully signed transactions (can be any type, including MCP).
- MCP-Specific Transaction Ingestion (for pre-signed/component-provided transactions):
POST /mcp/capability/register: Submits anMCPRegisterCapabilityTransaction.POST /mcp/capability/invoke: Submits anMCPInvokeCapabilityTransaction.
- MCP Data Querying:
GET /mcp/capability/{capability_id}: Retrieves a capability descriptor.GET /mcp/capabilities?type=<X>&owner=<Y>&...: Lists capabilities with filters.GET /mcp/context/{context_id}: Retrieves a specific context record.GET /mcp/capability/{capability_id}/invocations: Retrieves all context records for a capability.GET /mcp/contexts?capabilityId=<X>&interactionType=<Y>&...: Advanced querying for context records.
- Other Endpoints: For blockchain status, blocks, NRN balances, etc.
Provides a higher-level interface for clients, handling transaction creation and signing.
POST /wallet/mcp/create_register_capability: Creates, signs, and submits anMCPRegisterCapabilityTransaction.POST /wallet/mcp/create_invoke_capability: Creates, signs, and submits anMCPInvokeCapabilityTransaction.- Other endpoints for wallet management, generic transaction sending, etc.
-
Storing full capability descriptors on-chain is generally fine as they are metadata.
-
For
ResourceDescriptors, especiallyResourceTypePlugin,ResourceTypeDataset, orResourceTypeModelArtifact, theContentHashandLocationHintsfields are designed to point to off-chain storage (e.g., dev hosting, IPFS) for the actual large data, keeping the blockchain lean. The on-chain hash guarantees integrity. -
Initial Approach: Store them fully on-chain as per the blog's emphasis on verifiability.
-
- Current Model for Plugins: The
ResourceDescriptorstores metadata, includingContentHashof the package andSchema.LocationHints(URIs) pointing to the off-chain package. The on-chain hash guarantees integrity of the downloaded package.
- Current Model for Plugins: The
-
*Enhanced Querying with RealmDB (Supplemental):
While LevelDB serves as the primary storage for the blockchain and basic MCP data indexing, future enhancements could involve using RealmDB as a supplemental, rich secondary index for MCP data.
How it would work:
- LevelDB remains the source of truth for the blockchain.
- As blocks are processed, MCP data (
CapabilityDescriptors,ContextRecords) would be extracted and also written into a local RealmDB instance on each node. - This RealmDB instance would act as a highly queryable, object-oriented cache or materialized view.
- The API layer would direct complex analytical queries to RealmDB, while simple lookups might still use LevelDB.
Benefits of Supplemental RealmDB:
- Rich Queries: Handle complex multi-condition filtering, relationships, aggregations, and potentially full-text search over MCP data (e.g., "Find all Tools owned by 'Alice' with input schema containing 'image_url', invoked >10 times last week, ordered by fee").
- Object-Oriented Modeling: More natural mapping of Go MCP structs to database objects.
Challenges:
- Increased Complexity: Managing two database systems.
- Data Synchronization: Ensuring RealmDB accurately reflects the LevelDB state, especially during chain reorganizations (forks), requires robust rollback and re-indexing logic for the RealmDB portion.
This supplemental approach would allow AGENTCHAIN to offer significantly more powerful analytical capabilities over its MCP data without replacing the core LevelDB storage for the blockchain itself.
- Capability descriptors may need updates (e.g., new version, schema change, fee update).
- Approach: Implement updates by creating new registration transactions (e.g.,
MCPUpdateCapabilityTransaction) that reference the previous ID and create a new version. The blockchain will preserve the full history. Query APIs should default to the latest version but allow fetching specific versions.
- The proposed LevelDB indexing supports basic ID-based lookups and simple relationship queries.
- Future Enhancement: For more complex queries (e.g., "find all tools with input schema X and owned by Y"), an off-chain indexing/query service that syncs with the AGENTCHAIN blockchain might be necessary.
- The README mentions placeholder smart contract functionality. In the future, MCP logic (e.g., rules for updating cards, managing ownership, or more complex context validation) could be implemented as smart contracts for greater automation and decentralized governance.
- Who can register capabilities or invoke them? Initially, any valid transaction sender who can pay the fee.
- Future Enhancement: Implement on-chain access control mechanisms, possibly tied to ownership fields in the descriptors or through smart contracts (e.g., only owner can update a capability).
- The schemas for all
Descriptortypes andContextRecord(especially itsDetailsfield perInteractionType) should be well-documented and treated as part of the "protocol." Using JSON Schema forInputSchemaJSON,OutputSchemaJSON,ParametersSchemaJSON, and resourceSchemafields is already part of the design.
- This plan now explicitly incorporates NRN token gas fees via the
Transaction.Feefield andBaseDescriptor.GasFeeNRN. This necessitates the implementation of an account and balance system within AGENTCHAIN, which is a significant foundational requirement. - The "Sampling could be free" aspect means that
GasFeeNRNfor interactions logged related to sampling might be zero, or the transaction fee for such logging could be waived/minimal.
This plan provides a phased approach to integrating robust MCP functionality into AGENTCHAIN. By building upon its existing features, AGENTCHAIN can become a powerful platform for ensuring transparency and verifiability in AI workflows.
(This section would typically include instructions on how to build, run a node, interact with the API, etc. Placeholder for now.)
To build and run a AGENTCHAIN node:
```sh
git clone <repository_url>
cd AGENTCHAIN
go build -o AGENTCHAIN_node ./cmd/AGENTCHAIN/main.go
./AGENTCHAIN_node --port 8080 --p2p_port 6001
To run the Wallet Server:
go build -o wallet_server ./cmd/walletserver/main.go
./wallet_server --port 9090 --blockchain_server_ip http://localhost:8080(Details on how to contribute to the project. Placeholder for now.)
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
(Specify the project's license. Placeholder for now.)
This project is licensed under the MIT License.
This README provides:
* An overview of the MCP architecture as implemented.
* Clear explanations of core concepts like Capabilities, Descriptors, ContextRecords, and NRN tokens.
* Details on how Plugins are handled (on-chain registration, off-chain hosting, client-side execution).
* A summary of the data storage strategy (LevelDB primary, off-chain for large content).
* An outline of key API endpoints.
* A dedicated section on `ContextRecord` scenarios to highlight their importance.
* A "Future Considerations" section discussing the potential supplemental use of RealmDB for enhanced querying.
* Placeholders for "Getting Started," "Contributing," and "License" which you can fill in.
Let me know if you'd like any section expanded or modified!