forked from paiml/rust-mcp-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_currency_server.rs
More file actions
134 lines (118 loc) ยท 4.9 KB
/
test_currency_server.rs
File metadata and controls
134 lines (118 loc) ยท 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
//! Test the Currency Server manually
//!
//! This demonstrates what the currency server does by showing the MCP protocol
//! messages it expects and the responses it provides.
use serde_json::json;
fn main() {
println!("๐ฆ EU Currency MCP Server - What It Does");
println!("=========================================\n");
println!("The currency server is an MCP (Model Context Protocol) server that provides");
println!("4 powerful tools for currency analysis. Here's what each tool does:\n");
// Tool 1: get_rates
println!("๐ฑ TOOL 1: get_rates");
println!("--------------------");
println!("Purpose: Get current exchange rates for a base currency");
println!("Input example:");
println!(
"{}",
serde_json::to_string_pretty(&json!({
"base": "EUR",
"symbols": "USD,GBP,CHF"
}))
.unwrap()
);
println!("\nOutput: Current exchange rates with timestamp");
println!("Example: EUR โ USD: 1.0847, EUR โ GBP: 0.8312, etc.\n");
// Tool 2: analyze_trend
println!("๐ TOOL 2: analyze_trend");
println!("------------------------");
println!("Purpose: Comprehensive currency trend analysis with predictions");
println!("Input example:");
println!(
"{}",
serde_json::to_string_pretty(&json!({
"base": "EUR",
"target": "USD",
"days": 30,
"predict_days": 7
}))
.unwrap()
);
println!("\nOutput: Detailed analysis including:");
println!("โข Current rate and trend direction (โ๏ธ Rising/โ๏ธ Falling/โ Stable)");
println!("โข ASCII sparkline visualization: โโโโโ
โโโโโโ
โโโ");
println!("โข 7-day and 14-day moving averages");
println!("โข Linear regression predictions for next 1-30 days");
println!("โข Statistical analysis (volatility, range, data points)\n");
// Tool 3: list_currencies
println!("๐ TOOL 3: list_currencies");
println!("--------------------------");
println!("Purpose: List all supported currency codes");
println!("Input: {{}} (no parameters needed)");
println!("Output: EUR, USD, GBP, CHF, JPY, CAD, AUD, SEK, NOK, DKK, PLN, CZK, HUF, BGN, RON\n");
// Tool 4: get_historical
println!("๐
TOOL 4: get_historical");
println!("-------------------------");
println!("Purpose: Get historical exchange rates for a period");
println!("Input example:");
println!(
"{}",
serde_json::to_string_pretty(&json!({
"base": "USD",
"days": 30,
"symbols": "EUR,GBP"
}))
.unwrap()
);
println!("\nOutput: Historical rates for each day in the specified period\n");
println!("๐ง HOW TO USE THE SERVER:");
println!("=========================");
println!("1. The server runs as an MCP server (JSON-RPC over stdin/stdout)");
println!("2. It's designed to be used by MCP-compatible clients like:");
println!(" โข Claude Desktop with MCP integration");
println!(" โข Custom MCP clients");
println!(" โข AI assistants that support MCP protocol");
println!("3. When you run 'cargo run --example currency_server', it starts");
println!(" listening for MCP protocol messages on stdin");
println!("4. The server provides rich, formatted analysis reports with:");
println!(" โข Real-time exchange rates");
println!(" โข Historical trend analysis");
println!(" โข Statistical predictions");
println!(" โข Visual sparkline charts");
println!(" โข Moving averages and volatility metrics\n");
println!("๐ก EXAMPLE ANALYSIS OUTPUT:");
println!("===========================");
println!(
r#"Currency Trend Analysis: EUR โ USD
==========================================
๐ Current Rate: 1.0847
๐ Trend: โ๏ธ Rising
๐
Analysis Period: 30 days
๐ Rate Visualization:
โโโโ
โโโโโโ
โโโโโโโโ
โโโโโโ
โโโโโโ
โโ
๐ Moving Averages:
โข 7-day MA: 1.0834
โข 14-day MA: 1.0821
๐ฎ Predictions (next 7 days):
Day 1: 1.0851
Day 2: 1.0855
Day 3: 1.0859
Day 4: 1.0863
Day 5: 1.0867
Day 6: 1.0871
Day 7: 1.0875
๐ก Analysis:
โข Total data points: 30
โข Rate range: 1.0801 - 1.0893
โข Volatility: 0.8465%"#
);
println!("\n\n๐ INTEGRATION:");
println!("===============");
println!("This server demonstrates advanced MCP capabilities and can be:");
println!("โข Integrated with AI assistants for financial analysis");
println!("โข Used in trading applications for trend analysis");
println!("โข Extended with real API integration (Frankfurter, Alpha Vantage)");
println!("โข Deployed as part of larger financial analysis pipelines");
println!("\nโจ The server showcases the power of the PMCP Rust SDK for building");
println!(" sophisticated financial analysis tools with the MCP protocol!");
}