-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a254ba5
commit 3e28b57
Showing
8 changed files
with
444 additions
and
234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
build-and-release: | ||
name: Build and Release | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- os: ubuntu-latest | ||
target: x86_64-unknown-linux-gnu | ||
artifact_name: solana-mcp-server | ||
asset_name: solana-mcp-server-linux-amd64 | ||
- os: macos-latest | ||
target: x86_64-apple-darwin | ||
artifact_name: solana-mcp-server | ||
asset_name: solana-mcp-server-macos-amd64 | ||
- os: macos-latest | ||
target: aarch64-apple-darwin | ||
artifact_name: solana-mcp-server | ||
asset_name: solana-mcp-server-macos-arm64 | ||
- os: windows-latest | ||
target: x86_64-pc-windows-msvc | ||
artifact_name: solana-mcp-server.exe | ||
asset_name: solana-mcp-server-windows-amd64.exe | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: ${{ matrix.target }} | ||
|
||
- name: Build | ||
run: | | ||
cargo build --release --target ${{ matrix.target }} | ||
- name: Prepare asset | ||
shell: bash | ||
run: | | ||
mkdir -p release | ||
if [ "${{ matrix.os }}" = "windows-latest" ]; then | ||
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} release/${{ matrix.asset_name }} | ||
else | ||
cp target/${{ matrix.target }}/release/${{ matrix.artifact_name }} release/${{ matrix.asset_name }} | ||
chmod +x release/${{ matrix.asset_name }} | ||
fi | ||
- name: Upload Release Asset | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: release/${{ matrix.asset_name }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
create-release: | ||
name: Create Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Get version from tag | ||
id: get_version | ||
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: softprops/action-gh-release@v1 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
name: Release ${{ steps.get_version.outputs.VERSION }} | ||
draft: false | ||
prerelease: false | ||
generate_release_notes: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
pub mod rpc; | ||
pub mod server; | ||
pub mod tools; | ||
pub mod transport; | ||
|
||
pub use server::start_server; | ||
pub use transport::CustomStdioTransport; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,6 @@ | ||
use anyhow::Result; | ||
use clap::Parser; | ||
use solana_mcp_server::start_server; | ||
|
||
#[derive(Parser, Debug)] | ||
#[command(author, version, about, long_about = None)] | ||
struct Config { | ||
#[arg(long)] | ||
iam_agent: bool, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let _config = Config::parse(); | ||
start_server().await | ||
solana_mcp_server::server::start_server().await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
use anyhow::Result; | ||
use std::io::{self, BufRead, Write}; | ||
use crate::transport::{Transport, JsonRpcMessage}; | ||
use crate::CustomStdioTransport; | ||
use serde_json::Value; | ||
|
||
pub async fn start_server() -> Result<()> { | ||
eprintln!("Solana MCP server ready - {} v{}", | ||
env!("CARGO_PKG_NAME"), | ||
env!("CARGO_PKG_VERSION") | ||
); | ||
|
||
let stdin = io::stdin(); | ||
let mut stdout = io::stdout(); | ||
let mut reader = stdin.lock(); | ||
let mut line = String::new(); | ||
let transport = CustomStdioTransport::new(); | ||
transport.open()?; | ||
|
||
loop { | ||
line.clear(); | ||
match reader.read_line(&mut line) { | ||
Ok(0) => continue, | ||
Ok(_) => { | ||
if !line.trim().is_empty() { | ||
let response = crate::tools::handle_request(&line).await?; | ||
writeln!(stdout, "{}", serde_json::to_string_pretty(&response)?)?; | ||
stdout.flush()?; | ||
match transport.receive() { | ||
Ok(message) => { | ||
let message_str = serde_json::to_string(&message)?; | ||
let response = crate::tools::handle_request(&message_str).await?; | ||
transport.send(&response)?; | ||
} | ||
Err(e) => { | ||
if e.to_string().contains("Connection closed") { | ||
eprintln!("Client disconnected"); | ||
break; | ||
} | ||
eprintln!("Error receiving message: {}", e); | ||
} | ||
Err(e) => eprintln!("Error reading input: {}", e), | ||
} | ||
} | ||
|
||
transport.close()?; | ||
Ok(()) | ||
} |
Oops, something went wrong.