solana-dev-context-adapter
A utility suite designed for interacting with the Solana ledger via RPC interfaces, enabling the retrieval of ledger state (like account balances and transaction histories) and providing foundational development aids. It exposes key Solana remote procedure call functionalities.
Author

solana-foundation
Quick Info
Actions
Tags
Solana Model Context Protocol (MCP) Demonstration Repository
This repository illustrates a minimal implementation of a Model Context Protocol (MCP) server specifically tailored for Solana development workflows.
What is MCP?
The Model Context Protocol (MCP) defines a universal contract allowing sophisticated AI agents to interface with external systems and knowledge bases. This demonstration showcases a basic MCP server configuration providing:
- Core Remote Procedure Calls targeting Solana primitives (e.g.,
getBalance,getAccountInfo,getTransaction). - Curated instructional prompts relevant to Solana engineering tasks.
Prerequisites for Setup
Ensure you have the following software installed on your local environment:
- Node.js (version 16 or newer is preferred)
- The pnpm package manager (version 9.10.0 or a compatible release)
Installation Procedure
Acquire this repository and install necessary dependencies:
bash git clone https://github.com/solana-foundation/solana-dev-mcp.git cd solana-dev-mcp pnpm install
To initiate the server listener within the MCP inspector environment, execute:
bash npx @modelcontextprotocol/inspector ts-node index.ts
Initial Steps
-
Codebase Review: The central logic resides in
index.ts, establishing the MCP endpoint and integrating the initial set of fetching utilities and contextual suggestions. -
Customization: Feel free to augment the server definition by incorporating supplementary tools, external data sources, or refined prompts.
-
Extension Inspiration: Refer to the Expansion Opportunities for Solana Development section below for concepts on developing new integrated utilities and resource handlers.
Consumption Guidance
This guide details how to integrate the Solana MCP adapter with various AI platforms supporting the protocol, such as Claude. Identical configuration steps apply when deploying the adapter with Windsurf or the Cursor IDE.
Configuration File Generation
A dedicated configuration manifest is required for the consuming AI to establish a connection path to the server. Execute one of the following commands to produce this necessary JSON artifact:
- If
ts-nodeis present in your global environment:pnpm generate-config - If
ts-nodeis not installed globally:pnpm build && pnpm generate-config:js
This action will output a JSON configuration block structured as follows:
If using ts-node globally:
{
"mcpServers": {
"solana-dev": {
"command": "ts-node",
"args": ["
If relying solely on compiled JavaScript output:
{
"mcpServers": {
"solana-dev": {
"command": "node",
"args": ["
Directory Layout Overview
index.ts- Primary server bootstrap and implementation file.package.json- Metadata defining project structure and dependencies.tsconfig.json- Configuration settings for the TypeScript compiler.
Expansion Opportunities for Solana Development
This foundational MCP server implementation is designed to be a starting point. Feel free to fork or extend it to suit specialized Solana engineering requirements. Below are several conceptual enhancements:
Potential Tooling Enhancements
-
Optimal Fee Oracle: Integrate a utility to dynamically calculate and suggest optimal priority fees for transactions by analyzing recent network congestion metrics.
-
Verification Debug Assist: Develop a diagnostic tool to surface enhanced telemetry for troubleshooting issues encountered during
solana-verifyoperations. -
Program Security Manifest Reader: Construct a utility to fetch and present the contents of a program's
security.txtfile, streamlining communication regarding security vulnerabilities. -
Squads Orchestration Utility: Build automation scripts to streamline the deployment and version management workflows for Solana programs within a multi-signer governance context (like Squads).
-
Anchor Error Decoder: Create a service that translates raw Anchor error codes into descriptive, human-readable messages by querying an Anchor error registry.
-
Contextual Prompt Augmentation: Enhance the server's existing prompt set to offer more sophisticated, task-specific suggestions covering transaction construction patterns, new account initialization, or token mechanics.
-
Complex Transaction Assembler: Introduce tools that abstract the complexity of building multi-instruction transactions targeting various deployed Solana programs.
-
Custom RPC Endpoint Management: Implement configuration options allowing users to specify non-default RPC targets, supporting private infrastructure or localized cluster endpoints.
-
Program Lifecycle Tools: Develop helpers to simplify the often-complex procedures involved in deploying and subsequently upgrading on-chain programs.
-
State and History Viewer: Add a function that accepts an account address or transaction hash and renders its serialized data into a clear, easily digestible format, similar to a web explorer view.
-
Integrated Documentation Resources: Incorporate resource handlers that pull and serve documentation from the official Solana, Anchor, and protocol repositories directly within the MCP-enabled editor environment.
Contribution Guidelines
If you engineer a useful extension, we encourage submitting a Pull Request. Adherence to the following standards is requested:
- Ensure all new code is thoroughly documented.
- Include comprehensive unit tests for all new features.
- Maintain consistency with the existing codebase's stylistic conventions.
- Update this README document to reflect the capabilities of your contribution.
Security Advisory
This implementation serves purely as an educational reference and is not production-ready. The Model Context Protocol is an emerging specification lacking mature, established security hardening.
Exercise extreme prudence when deploying or invoking MCP services sourced from unverified repositories.
It is strongly recommended to utilize this software exclusively within isolated, sandboxed environments to mitigate any risk of data exposure or system compromise.
WIKIPEDIA: XMLHttpRequest (XHR) is an Application Programming Interface defined as a JavaScript object whose methods facilitate the transmission of HTTP requests from a web browser back-end to a remote web server. These methods empower a client-side application to dispatch inquiries to the server post-page load and subsequently receive data in response. XMLHttpRequest forms a foundational element of Asynchronous JavaScript and XML (Ajax) programming paradigms. Prior to Ajax adoption, the standard mechanisms for server interaction relied heavily on standard hyperlinks and HTML form submissions, which typically necessitated a full page refresh upon completion.
== Historical Context ==
The foundational concept enabling XMLHttpRequest originated in the year 2000, conceived by software architects working on Microsoft Outlook. This concept was subsequently integrated into the Internet Explorer 5 browser release (1999). Crucially, the initial implementation did not utilize the standardized XMLHttpRequest identifier. Instead, developers relied on COM object instantiation via ActiveXObject("Msxml2.XMLHTTP") and ActiveXObject("Microsoft.XMLHTTP"). By the time Internet Explorer 7 launched (2006), support for the standardized XMLHttpRequest identifier had become universal across the platform.
As of today, the XMLHttpRequest identifier represents the dominant convention across all major browser engines, including Mozilla’s Gecko (adopted in 2002), Safari 1.2 (2004), and Opera 8.0 (2005).
=== Standardization Efforts ===
The World Wide Web Consortium (W3C) officially published a Working Draft specification detailing the XMLHttpRequest object on April 5, 2006. A subsequent Working Draft for Level 2 was released by the W3C on February 25, 2008. The Level 2 specification introduced vital enhancements, such as mechanisms for tracking request progress, enabling requests across differing domains (cross-site), and facilitating the handling of raw byte streams. By the close of 2011, the innovations introduced in the Level 2 draft were formally merged back into the primary specification document.
In late 2012, the stewardship of the specification was transferred to the WHATWG group, which now maintains a continuously evolving document utilizing the Web IDL interface description language.
== Operational Use Cases == Generally, the process of dispatching a request using XMLHttpRequest involves several discrete programming milestones:
Instantiate an XMLHttpRequest object by invocation of its constructor:
Invoke the open method to define the request method (e.g., GET/POST), specify the target resource URI, and elect between synchronous or asynchronous execution modes:
For operations designated as asynchronous, install an event listener callback function that will be triggered upon changes in the request's state:
Commence the request transmission sequence by calling the send method:
Implement logic within the state change listener to react to status updates. Upon successful server response, the object transitions to state 4, signifying the "done" status, with the payload typically residing in the responseText attribute.
Beyond these fundamental stages, XMLHttpRequest offers extensive configuration capabilities to govern request transmission protocols and response processing methods. Custom header fields can be programmatically affixed to the outgoing request to instruct the server on desired fulfillment parameters, and data payload can be transferred to the server via arguments passed to the send invocation. The received response data can be automatically deserialized from JSON format into native JavaScript structures, or alternatively, processed incrementally as data arrives, bypassing the need to wait for the entire body to download. Furthermore, the request can be canceled prematurely or configured with a timeout threshold to enforce failure if completion is not achieved within a set duration.
== Inter-Domain Communications == During the nascent phases of the World Wide Web, limitations were encountered regarding the feasibility of initiating data transfers across distinct security domains, which quickly became apparent...
