@virga-mcp/server 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +192 -0
- package/dist/client.d.ts +170 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +159 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts.d.ts +6 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +67 -0
- package/dist/prompts.js.map +1 -0
- package/dist/resources.d.ts +7 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +239 -0
- package/dist/resources.js.map +1 -0
- package/dist/tools.d.ts +7 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +326 -0
- package/dist/tools.js.map +1 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# @virga-mcp/server
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) server for the [Virga Weather API](https://api.virga.dev). Exposes weather data as native tools for LLM clients.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
### Claude Code
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
claude mcp add --transport stdio --env VIRGA_API_KEY=sk_virga_prod_xxx virga-weather -- npx -y @virga-mcp/server
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Codex CLI
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
codex mcp add virga-weather --env VIRGA_API_KEY=sk_virga_prod_xxx -- npx -y @virga-mcp/server
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Gemini CLI
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
gemini mcp add virga-weather -- npx -y @virga-mcp/server --api-key sk_virga_prod_xxx
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or add to `~/.gemini/settings.json`:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"mcpServers": {
|
|
30
|
+
"virga-weather": {
|
|
31
|
+
"command": "npx",
|
|
32
|
+
"args": ["-y", "@virga-mcp/server", "--api-key", "sk_virga_prod_xxx"]
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Claude Desktop
|
|
39
|
+
|
|
40
|
+
Add to your config file:
|
|
41
|
+
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
42
|
+
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
43
|
+
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"mcpServers": {
|
|
47
|
+
"virga-weather": {
|
|
48
|
+
"command": "npx",
|
|
49
|
+
"args": ["-y", "@virga-mcp/server"],
|
|
50
|
+
"env": {
|
|
51
|
+
"VIRGA_API_KEY": "sk_virga_prod_xxx"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Cursor
|
|
59
|
+
|
|
60
|
+
Add as an MCP server in Cursor settings (Settings > MCP Servers), or add to `.cursor/mcp.json`:
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"mcpServers": {
|
|
65
|
+
"virga-weather": {
|
|
66
|
+
"command": "npx",
|
|
67
|
+
"args": ["-y", "@virga-mcp/server", "--api-key", "sk_virga_prod_xxx"]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Windsurf
|
|
74
|
+
|
|
75
|
+
Add to your MCP configuration:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"virga-weather": {
|
|
80
|
+
"command": "npx",
|
|
81
|
+
"args": ["-y", "@virga-mcp/server", "--api-key", "sk_virga_prod_xxx"]
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### OpenCode
|
|
87
|
+
|
|
88
|
+
Add to `opencode.json`:
|
|
89
|
+
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"mcp": {
|
|
93
|
+
"virga-weather": {
|
|
94
|
+
"type": "local",
|
|
95
|
+
"command": ["npx", "-y", "@virga-mcp/server"],
|
|
96
|
+
"environment": {
|
|
97
|
+
"VIRGA_API_KEY": "sk_virga_prod_xxx"
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Xcode (26.3+)
|
|
105
|
+
|
|
106
|
+
Xcode 26.3 has native MCP support. Add to your Xcode MCP configuration:
|
|
107
|
+
|
|
108
|
+
```json
|
|
109
|
+
{
|
|
110
|
+
"servers": {
|
|
111
|
+
"virga-weather": {
|
|
112
|
+
"command": "npx",
|
|
113
|
+
"arguments": ["-y", "@virga-mcp/server"],
|
|
114
|
+
"environment": {
|
|
115
|
+
"VIRGA_API_KEY": "sk_virga_prod_xxx"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Environment Variable
|
|
123
|
+
|
|
124
|
+
You can also set the API key as an environment variable instead of passing it as a flag:
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
VIRGA_API_KEY=sk_virga_prod_xxx npx @virga-mcp/server
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Weather Tools
|
|
131
|
+
|
|
132
|
+
| Tool | Description | Credits |
|
|
133
|
+
|------|-------------|---------|
|
|
134
|
+
| `get_current_weather` | Current weather conditions for a lat/lon | 1 |
|
|
135
|
+
| `get_hourly_forecast` | Hourly forecast (1-120 hours) | 2 |
|
|
136
|
+
| `get_daily_forecast` | Daily forecast (1-16 days) | 2 |
|
|
137
|
+
| `get_historical_weather` | Historical weather for a specific date | 3 |
|
|
138
|
+
| `search_location` | Geocode a place name to lat/lon | 0 (free) |
|
|
139
|
+
|
|
140
|
+
## Account & Billing Tools
|
|
141
|
+
|
|
142
|
+
| Tool | Description |
|
|
143
|
+
|------|-------------|
|
|
144
|
+
| `create_account` | Create a new account, get a stage API key |
|
|
145
|
+
| `accept_terms` | Accept the current terms of service |
|
|
146
|
+
| `activate_billing` | Set up payment method (returns Stripe checkout URL) |
|
|
147
|
+
| `purchase_credits` | Buy a credit bundle (returns Stripe checkout URL) |
|
|
148
|
+
| `get_billing_status` | Credit balance, spend caps, auto-topup config |
|
|
149
|
+
| `list_api_keys` | List all API keys for the account |
|
|
150
|
+
| `create_api_key` | Create a new API key (stage or production) |
|
|
151
|
+
| `revoke_api_key` | Permanently revoke an API key |
|
|
152
|
+
| `get_usage` | API usage history with credit costs |
|
|
153
|
+
|
|
154
|
+
## Resources
|
|
155
|
+
|
|
156
|
+
| Resource | URI | Description |
|
|
157
|
+
|----------|-----|-------------|
|
|
158
|
+
| Account Status | `weather://account/status` | Credit balance, rate limits, usage |
|
|
159
|
+
| Terms | `weather://terms` | Current terms of service |
|
|
160
|
+
| Pricing | `weather://pricing` | Credit costs per tool and bundles |
|
|
161
|
+
| OpenAPI Spec | `weather://openapi` | Full OpenAPI 3.1 specification |
|
|
162
|
+
| Onboarding | `weather://onboarding` | Step-by-step autonomous setup guide |
|
|
163
|
+
| Docs | `weather://docs` | Condensed LLM-friendly documentation |
|
|
164
|
+
|
|
165
|
+
## Prompt Templates
|
|
166
|
+
|
|
167
|
+
| Prompt | Description |
|
|
168
|
+
|--------|-------------|
|
|
169
|
+
| `setup_weather_account` | Guided walkthrough for account creation and billing setup |
|
|
170
|
+
| `check_weather` | Check current weather at a location by name |
|
|
171
|
+
| `weather_forecast` | Get a daily or hourly forecast for a location |
|
|
172
|
+
|
|
173
|
+
## CLI Options
|
|
174
|
+
|
|
175
|
+
| Flag | Description | Default |
|
|
176
|
+
|------|-------------|---------|
|
|
177
|
+
| `--api-key <key>` | Virga API key | `VIRGA_API_KEY` env var |
|
|
178
|
+
| `--base-url <url>` | API base URL | `https://api.virga.dev` |
|
|
179
|
+
| `--help` | Show help | |
|
|
180
|
+
| `--version` | Show version | |
|
|
181
|
+
|
|
182
|
+
## Getting an API Key
|
|
183
|
+
|
|
184
|
+
Use the `setup_weather_account` prompt template, or follow these steps:
|
|
185
|
+
|
|
186
|
+
1. Create an account: `POST https://api.virga.dev/api/v1/accounts`
|
|
187
|
+
2. Accept terms: `POST https://api.virga.dev/api/v1/terms/accept`
|
|
188
|
+
3. Set up billing: `POST https://api.virga.dev/api/v1/billing/activate`
|
|
189
|
+
4. Purchase credits: `POST https://api.virga.dev/api/v1/billing/credits`
|
|
190
|
+
5. Create a production key: `POST https://api.virga.dev/api/v1/keys`
|
|
191
|
+
|
|
192
|
+
Or use a stage key (free, no credits required) for testing.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the Virga Weather API.
|
|
3
|
+
*/
|
|
4
|
+
export interface VirgaClientConfig {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class VirgaClient {
|
|
9
|
+
private apiKey;
|
|
10
|
+
private baseUrl;
|
|
11
|
+
constructor(config: VirgaClientConfig);
|
|
12
|
+
private request;
|
|
13
|
+
getCurrentWeather(lat: number, lon: number): Promise<WeatherResponse>;
|
|
14
|
+
getHourlyForecast(lat: number, lon: number, hours?: number): Promise<ForecastResponse>;
|
|
15
|
+
getDailyForecast(lat: number, lon: number, days?: number): Promise<ForecastResponse>;
|
|
16
|
+
getHistoricalWeather(lat: number, lon: number, date: string): Promise<WeatherResponse>;
|
|
17
|
+
createAccount(name: string): Promise<CreateAccountResponse>;
|
|
18
|
+
getAccount(): Promise<AccountResponse>;
|
|
19
|
+
getUsage(options?: {
|
|
20
|
+
start?: string;
|
|
21
|
+
end?: string;
|
|
22
|
+
limit?: number;
|
|
23
|
+
}): Promise<UsageResponse>;
|
|
24
|
+
listApiKeys(): Promise<ApiKeysResponse>;
|
|
25
|
+
createApiKey(name: string, environment?: string): Promise<CreateApiKeyResponse>;
|
|
26
|
+
revokeApiKey(keyId: string): Promise<{
|
|
27
|
+
message: string;
|
|
28
|
+
}>;
|
|
29
|
+
getTerms(): Promise<TermsResponse>;
|
|
30
|
+
acceptTerms(version: string): Promise<{
|
|
31
|
+
message: string;
|
|
32
|
+
}>;
|
|
33
|
+
getOpenApiSpec(): Promise<string>;
|
|
34
|
+
getDocs(): Promise<string>;
|
|
35
|
+
activateBilling(): Promise<{
|
|
36
|
+
checkoutUrl: string;
|
|
37
|
+
}>;
|
|
38
|
+
purchaseCredits(bundle: string): Promise<{
|
|
39
|
+
checkoutUrl: string;
|
|
40
|
+
}>;
|
|
41
|
+
getBillingStatus(): Promise<BillingStatusResponse>;
|
|
42
|
+
private requestNoAuth;
|
|
43
|
+
}
|
|
44
|
+
export declare class VirgaApiError extends Error {
|
|
45
|
+
status: number;
|
|
46
|
+
code: string;
|
|
47
|
+
constructor(message: string, status: number, code: string);
|
|
48
|
+
}
|
|
49
|
+
export interface NormalizedWeather {
|
|
50
|
+
temperature: {
|
|
51
|
+
current: number;
|
|
52
|
+
feelsLike: number;
|
|
53
|
+
min: number;
|
|
54
|
+
max: number;
|
|
55
|
+
unit: string;
|
|
56
|
+
};
|
|
57
|
+
humidity: number;
|
|
58
|
+
pressure: number;
|
|
59
|
+
wind: {
|
|
60
|
+
speed: number;
|
|
61
|
+
direction: number;
|
|
62
|
+
gust: number | null;
|
|
63
|
+
unit: string;
|
|
64
|
+
};
|
|
65
|
+
precipitation: {
|
|
66
|
+
probability: number | null;
|
|
67
|
+
amount: number;
|
|
68
|
+
unit: string;
|
|
69
|
+
};
|
|
70
|
+
conditions: {
|
|
71
|
+
code: number;
|
|
72
|
+
description: string;
|
|
73
|
+
icon: string;
|
|
74
|
+
};
|
|
75
|
+
visibility: number;
|
|
76
|
+
uv: number | null;
|
|
77
|
+
clouds: number;
|
|
78
|
+
}
|
|
79
|
+
export interface WeatherMeta {
|
|
80
|
+
source: string;
|
|
81
|
+
upstreamTimestamp: string;
|
|
82
|
+
cacheTTL: number;
|
|
83
|
+
cached: boolean;
|
|
84
|
+
confidence: number;
|
|
85
|
+
creditsCost: number;
|
|
86
|
+
creditsRemaining: number;
|
|
87
|
+
environment: string;
|
|
88
|
+
rateLimitRemaining: number;
|
|
89
|
+
rateLimitReset: number;
|
|
90
|
+
}
|
|
91
|
+
export interface Location {
|
|
92
|
+
lat: number;
|
|
93
|
+
lon: number;
|
|
94
|
+
name: string | null;
|
|
95
|
+
}
|
|
96
|
+
export interface WeatherResponse {
|
|
97
|
+
data: NormalizedWeather;
|
|
98
|
+
location: Location;
|
|
99
|
+
timestamp: string;
|
|
100
|
+
meta: WeatherMeta;
|
|
101
|
+
}
|
|
102
|
+
export interface ForecastResponse {
|
|
103
|
+
data: NormalizedWeather[];
|
|
104
|
+
location: Location;
|
|
105
|
+
meta: WeatherMeta;
|
|
106
|
+
}
|
|
107
|
+
export interface AccountResponse {
|
|
108
|
+
accountId: string;
|
|
109
|
+
name: string;
|
|
110
|
+
email?: string;
|
|
111
|
+
environment: string;
|
|
112
|
+
status: string;
|
|
113
|
+
termsAcceptedVersion?: string;
|
|
114
|
+
billingActivated: boolean;
|
|
115
|
+
creditBalance: number;
|
|
116
|
+
dailySpendCap: number;
|
|
117
|
+
monthlySpendCap: number;
|
|
118
|
+
createdAt: number;
|
|
119
|
+
activeKeyCount: number;
|
|
120
|
+
}
|
|
121
|
+
export interface UsageResponse {
|
|
122
|
+
usage: Array<{
|
|
123
|
+
endpoint: string;
|
|
124
|
+
creditsCost: number;
|
|
125
|
+
timestamp: number;
|
|
126
|
+
cached: boolean;
|
|
127
|
+
environment: string;
|
|
128
|
+
}>;
|
|
129
|
+
}
|
|
130
|
+
export interface TermsResponse {
|
|
131
|
+
version: string;
|
|
132
|
+
text: string;
|
|
133
|
+
accepted: boolean;
|
|
134
|
+
acceptedAt: number | null;
|
|
135
|
+
}
|
|
136
|
+
export interface CreateAccountResponse {
|
|
137
|
+
accountId: string;
|
|
138
|
+
apiKey: string;
|
|
139
|
+
environment: string;
|
|
140
|
+
message: string;
|
|
141
|
+
}
|
|
142
|
+
export interface ApiKeysResponse {
|
|
143
|
+
keys: Array<{
|
|
144
|
+
keyPrefix: string;
|
|
145
|
+
name: string;
|
|
146
|
+
environment: string;
|
|
147
|
+
status: string;
|
|
148
|
+
createdAt: number;
|
|
149
|
+
lastUsedAt?: number;
|
|
150
|
+
}>;
|
|
151
|
+
}
|
|
152
|
+
export interface CreateApiKeyResponse {
|
|
153
|
+
apiKey: string;
|
|
154
|
+
keyPrefix: string;
|
|
155
|
+
environment: string;
|
|
156
|
+
message: string;
|
|
157
|
+
}
|
|
158
|
+
export interface BillingStatusResponse {
|
|
159
|
+
creditBalance: number;
|
|
160
|
+
billingActivated: boolean;
|
|
161
|
+
stripeCustomerId?: string;
|
|
162
|
+
dailySpendCap: number;
|
|
163
|
+
monthlySpendCap: number;
|
|
164
|
+
autoTopup?: {
|
|
165
|
+
enabled: boolean;
|
|
166
|
+
threshold: number;
|
|
167
|
+
bundle: string;
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAAS;gBAEZ,MAAM,EAAE,iBAAiB;YAKvB,OAAO;IAmCf,iBAAiB,CAA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AM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE;QACV,OAAO,EAAE,OAAO,CAAC;QACjB,SAAS,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;CACH"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the Virga Weather API.
|
|
3
|
+
*/
|
|
4
|
+
const DEFAULT_BASE_URL = "https://api.virga.dev";
|
|
5
|
+
export class VirgaClient {
|
|
6
|
+
apiKey;
|
|
7
|
+
baseUrl;
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.apiKey = config.apiKey;
|
|
10
|
+
this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
|
|
11
|
+
}
|
|
12
|
+
async request(method, path, options) {
|
|
13
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
14
|
+
if (options?.params) {
|
|
15
|
+
for (const [k, v] of Object.entries(options.params)) {
|
|
16
|
+
if (v !== undefined && v !== "")
|
|
17
|
+
url.searchParams.set(k, v);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
const res = await fetch(url.toString(), {
|
|
21
|
+
method,
|
|
22
|
+
headers: {
|
|
23
|
+
"X-API-Key": this.apiKey,
|
|
24
|
+
...(options?.body ? { "Content-Type": "application/json" } : {}),
|
|
25
|
+
},
|
|
26
|
+
...(options?.body ? { body: JSON.stringify(options.body) } : {}),
|
|
27
|
+
});
|
|
28
|
+
const json = (await res.json());
|
|
29
|
+
if (!res.ok) {
|
|
30
|
+
const err = json;
|
|
31
|
+
throw new VirgaApiError(err.message ?? `API error ${res.status}`, res.status, err.code ?? "UNKNOWN");
|
|
32
|
+
}
|
|
33
|
+
return json;
|
|
34
|
+
}
|
|
35
|
+
// --- Weather ---
|
|
36
|
+
async getCurrentWeather(lat, lon) {
|
|
37
|
+
return this.request("GET", "/api/v1/weather/current", {
|
|
38
|
+
params: { lat: String(lat), lon: String(lon) },
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
async getHourlyForecast(lat, lon, hours) {
|
|
42
|
+
return this.request("GET", "/api/v1/weather/forecast/hourly", {
|
|
43
|
+
params: {
|
|
44
|
+
lat: String(lat),
|
|
45
|
+
lon: String(lon),
|
|
46
|
+
...(hours ? { hours: String(hours) } : {}),
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async getDailyForecast(lat, lon, days) {
|
|
51
|
+
return this.request("GET", "/api/v1/weather/forecast/daily", {
|
|
52
|
+
params: {
|
|
53
|
+
lat: String(lat),
|
|
54
|
+
lon: String(lon),
|
|
55
|
+
...(days ? { days: String(days) } : {}),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
async getHistoricalWeather(lat, lon, date) {
|
|
60
|
+
return this.request("GET", "/api/v1/weather/historical", {
|
|
61
|
+
params: { lat: String(lat), lon: String(lon), date },
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// --- Account ---
|
|
65
|
+
async createAccount(name) {
|
|
66
|
+
return this.requestNoAuth("POST", "/api/v1/accounts", {
|
|
67
|
+
body: { name },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
async getAccount() {
|
|
71
|
+
return this.request("GET", "/api/v1/account");
|
|
72
|
+
}
|
|
73
|
+
async getUsage(options) {
|
|
74
|
+
const params = {};
|
|
75
|
+
if (options?.start)
|
|
76
|
+
params.start = options.start;
|
|
77
|
+
if (options?.end)
|
|
78
|
+
params.end = options.end;
|
|
79
|
+
if (options?.limit)
|
|
80
|
+
params.limit = String(options.limit);
|
|
81
|
+
return this.request("GET", "/api/v1/account/usage", {
|
|
82
|
+
params,
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
// --- Keys ---
|
|
86
|
+
async listApiKeys() {
|
|
87
|
+
return this.request("GET", "/api/v1/keys");
|
|
88
|
+
}
|
|
89
|
+
async createApiKey(name, environment) {
|
|
90
|
+
return this.request("POST", "/api/v1/keys", {
|
|
91
|
+
body: { name, ...(environment ? { environment } : {}) },
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
async revokeApiKey(keyId) {
|
|
95
|
+
return this.request("DELETE", `/api/v1/keys/${keyId}`);
|
|
96
|
+
}
|
|
97
|
+
// --- Terms ---
|
|
98
|
+
async getTerms() {
|
|
99
|
+
return this.request("GET", "/api/v1/terms");
|
|
100
|
+
}
|
|
101
|
+
async acceptTerms(version) {
|
|
102
|
+
return this.request("POST", "/api/v1/terms/accept", {
|
|
103
|
+
body: { version },
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// --- Discovery ---
|
|
107
|
+
async getOpenApiSpec() {
|
|
108
|
+
const res = await fetch(`${this.baseUrl}/openapi.json`);
|
|
109
|
+
if (!res.ok)
|
|
110
|
+
throw new VirgaApiError(`Failed to fetch OpenAPI spec`, res.status, "FETCH_ERROR");
|
|
111
|
+
return res.text();
|
|
112
|
+
}
|
|
113
|
+
async getDocs() {
|
|
114
|
+
const res = await fetch(`${this.baseUrl}/llms.txt`);
|
|
115
|
+
if (!res.ok)
|
|
116
|
+
throw new VirgaApiError(`Failed to fetch docs`, res.status, "FETCH_ERROR");
|
|
117
|
+
return res.text();
|
|
118
|
+
}
|
|
119
|
+
// --- Billing ---
|
|
120
|
+
async activateBilling() {
|
|
121
|
+
return this.request("POST", "/api/v1/billing/activate");
|
|
122
|
+
}
|
|
123
|
+
async purchaseCredits(bundle) {
|
|
124
|
+
return this.request("POST", "/api/v1/billing/credits", {
|
|
125
|
+
body: { bundle },
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async getBillingStatus() {
|
|
129
|
+
return this.request("GET", "/api/v1/billing/status");
|
|
130
|
+
}
|
|
131
|
+
// --- Internal helpers ---
|
|
132
|
+
async requestNoAuth(method, path, options) {
|
|
133
|
+
const url = `${this.baseUrl}${path}`;
|
|
134
|
+
const res = await fetch(url, {
|
|
135
|
+
method,
|
|
136
|
+
headers: {
|
|
137
|
+
...(options?.body ? { "Content-Type": "application/json" } : {}),
|
|
138
|
+
},
|
|
139
|
+
...(options?.body ? { body: JSON.stringify(options.body) } : {}),
|
|
140
|
+
});
|
|
141
|
+
const json = (await res.json());
|
|
142
|
+
if (!res.ok) {
|
|
143
|
+
const err = json;
|
|
144
|
+
throw new VirgaApiError(err.message ?? `API error ${res.status}`, res.status, err.code ?? "UNKNOWN");
|
|
145
|
+
}
|
|
146
|
+
return json;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
export class VirgaApiError extends Error {
|
|
150
|
+
status;
|
|
151
|
+
code;
|
|
152
|
+
constructor(message, status, code) {
|
|
153
|
+
super(message);
|
|
154
|
+
this.status = status;
|
|
155
|
+
this.code = code;
|
|
156
|
+
this.name = "VirgaApiError";
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAOjD,MAAM,OAAO,WAAW;IACd,MAAM,CAAS;IACf,OAAO,CAAS;IAEx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ACF;AAED,MAAM,OAAO,aAAc,SAAQ,KAAK;IAG7B;IACA;IAHT,YACE,OAAe,EACR,MAAc,EACd,IAAY;QAEnB,KAAK,CAAC,OAAO,CAAC,CAAC;QAHR,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAGnB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Virga Weather MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Exposes the Virga Weather API as MCP tools and resources for LLM clients
|
|
6
|
+
* like Claude Code, Codex, Gemini CLI, Claude Desktop, Cursor, Windsurf, OpenCode, and Xcode.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* npx @virga-mcp/server --api-key sk_virga_prod_xxx
|
|
10
|
+
* VIRGA_API_KEY=sk_virga_prod_xxx npx @virga-mcp/server
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;GASG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Virga Weather MCP Server
|
|
4
|
+
*
|
|
5
|
+
* Exposes the Virga Weather API as MCP tools and resources for LLM clients
|
|
6
|
+
* like Claude Code, Codex, Gemini CLI, Claude Desktop, Cursor, Windsurf, OpenCode, and Xcode.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* npx @virga-mcp/server --api-key sk_virga_prod_xxx
|
|
10
|
+
* VIRGA_API_KEY=sk_virga_prod_xxx npx @virga-mcp/server
|
|
11
|
+
*/
|
|
12
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
13
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
14
|
+
import { VirgaClient } from "./client.js";
|
|
15
|
+
import { registerTools } from "./tools.js";
|
|
16
|
+
import { registerResources } from "./resources.js";
|
|
17
|
+
import { registerPrompts } from "./prompts.js";
|
|
18
|
+
function parseArgs(argv) {
|
|
19
|
+
const result = {};
|
|
20
|
+
for (let i = 0; i < argv.length; i++) {
|
|
21
|
+
if (argv[i] === "--api-key" && argv[i + 1]) {
|
|
22
|
+
result.apiKey = argv[++i];
|
|
23
|
+
}
|
|
24
|
+
else if (argv[i] === "--base-url" && argv[i + 1]) {
|
|
25
|
+
result.baseUrl = argv[++i];
|
|
26
|
+
}
|
|
27
|
+
else if (argv[i] === "--help" || argv[i] === "-h") {
|
|
28
|
+
printUsage();
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
else if (argv[i] === "--version" || argv[i] === "-v") {
|
|
32
|
+
console.error("@virga-mcp/server v0.1.0");
|
|
33
|
+
process.exit(0);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
function printUsage() {
|
|
39
|
+
console.error(`Virga Weather MCP Server
|
|
40
|
+
|
|
41
|
+
Usage:
|
|
42
|
+
virga-mcp --api-key <key>
|
|
43
|
+
VIRGA_API_KEY=<key> virga-mcp
|
|
44
|
+
|
|
45
|
+
Options:
|
|
46
|
+
--api-key <key> Virga API key (or set VIRGA_API_KEY env var)
|
|
47
|
+
--base-url <url> API base URL (default: https://api.virga.dev)
|
|
48
|
+
--help, -h Show this help message
|
|
49
|
+
--version, -v Show version
|
|
50
|
+
|
|
51
|
+
Quick Setup:
|
|
52
|
+
|
|
53
|
+
Claude Code:
|
|
54
|
+
claude mcp add --transport stdio --env VIRGA_API_KEY=sk_virga_prod_xxx virga-weather -- npx -y @virga-mcp/server
|
|
55
|
+
|
|
56
|
+
Codex CLI:
|
|
57
|
+
codex mcp add virga-weather --env VIRGA_API_KEY=sk_virga_prod_xxx -- npx -y @virga-mcp/server
|
|
58
|
+
|
|
59
|
+
Gemini CLI:
|
|
60
|
+
gemini mcp add virga-weather -- npx -y @virga-mcp/server --api-key sk_virga_prod_xxx
|
|
61
|
+
|
|
62
|
+
Cursor / Windsurf / Claude Desktop / OpenCode / Xcode:
|
|
63
|
+
See README for JSON configuration examples
|
|
64
|
+
`);
|
|
65
|
+
}
|
|
66
|
+
async function main() {
|
|
67
|
+
const args = parseArgs(process.argv.slice(2));
|
|
68
|
+
const apiKey = args.apiKey ?? process.env.VIRGA_API_KEY;
|
|
69
|
+
if (!apiKey) {
|
|
70
|
+
console.error("Error: API key required. Use --api-key <key> or set VIRGA_API_KEY environment variable.");
|
|
71
|
+
console.error('Run "virga-mcp --help" for usage information.');
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
const client = new VirgaClient({
|
|
75
|
+
apiKey,
|
|
76
|
+
baseUrl: args.baseUrl ?? process.env.VIRGA_BASE_URL,
|
|
77
|
+
});
|
|
78
|
+
const server = new McpServer({
|
|
79
|
+
name: "virga-weather",
|
|
80
|
+
version: "0.1.0",
|
|
81
|
+
});
|
|
82
|
+
registerTools(server, client);
|
|
83
|
+
registerResources(server, client);
|
|
84
|
+
registerPrompts(server);
|
|
85
|
+
const transport = new StdioServerTransport();
|
|
86
|
+
await server.connect(transport);
|
|
87
|
+
console.error("Virga Weather MCP Server running on stdio");
|
|
88
|
+
}
|
|
89
|
+
main().catch((error) => {
|
|
90
|
+
console.error("Fatal error:", error);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|
|
93
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;GASG;AAEH,OAAO,EAAE,SAAS,EAAE,M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