@sly_ai/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 +250 -0
- package/dist/chunk-4TYFE45V.js +1263 -0
- package/dist/chunk-7VGOP77O.js +2069 -0
- package/dist/chunk-DUH5YKYI.js +1334 -0
- package/dist/chunk-EHDJW7S4.js +1260 -0
- package/dist/chunk-HIYKNQTJ.js +1202 -0
- package/dist/chunk-IRPIEJZP.js +1929 -0
- package/dist/chunk-LB6XWJAE.js +1288 -0
- package/dist/chunk-OHTORKDB.js +1301 -0
- package/dist/chunk-Y5FGTJ5F.js +2072 -0
- package/dist/chunk-Y7U7ZXH5.js +1298 -0
- package/dist/chunk-YDZJAN2U.js +2042 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +44 -0
- package/dist/server-factory.d.ts +28 -0
- package/dist/server-factory.js +7 -0
- package/dist/tools.d.ts +12 -0
- package/dist/tools.js +6 -0
- package/package.json +51 -0
- package/src/index.test.ts +75 -0
- package/src/index.ts +72 -0
- package/src/server-factory.ts +1664 -0
- package/src/tools.ts +2064 -0
- package/tsconfig.json +15 -0
- package/vitest.config.ts +8 -0
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
createMcpServer
|
|
4
|
+
} from "./chunk-OHTORKDB.js";
|
|
5
|
+
import {
|
|
6
|
+
tools
|
|
7
|
+
} from "./chunk-YDZJAN2U.js";
|
|
8
|
+
|
|
9
|
+
// src/index.ts
|
|
10
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
11
|
+
import { Sly, getEnvironmentConfig } from "@sly/sdk";
|
|
12
|
+
var SLY_API_KEY = process.env.SLY_API_KEY;
|
|
13
|
+
var SLY_API_KEY_LIVE = process.env.SLY_API_KEY_LIVE;
|
|
14
|
+
var SLY_ENVIRONMENT = process.env.SLY_ENVIRONMENT || "sandbox";
|
|
15
|
+
if (!SLY_API_KEY) {
|
|
16
|
+
console.error("Error: SLY_API_KEY environment variable is required");
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
var sly = new Sly({
|
|
20
|
+
apiKey: SLY_API_KEY,
|
|
21
|
+
environment: SLY_ENVIRONMENT,
|
|
22
|
+
apiUrl: process.env.SLY_API_URL
|
|
23
|
+
});
|
|
24
|
+
var SLY_API_URL = process.env.SLY_API_URL || getEnvironmentConfig(SLY_ENVIRONMENT).apiUrl;
|
|
25
|
+
var keys = { sandbox: SLY_API_KEY };
|
|
26
|
+
if (SLY_API_KEY_LIVE) keys.production = SLY_API_KEY_LIVE;
|
|
27
|
+
var SLY_API_URL_LIVE = process.env.SLY_API_URL_LIVE;
|
|
28
|
+
var urls = { sandbox: SLY_API_URL };
|
|
29
|
+
if (SLY_API_URL_LIVE) urls.production = SLY_API_URL_LIVE;
|
|
30
|
+
var server = createMcpServer(sly, SLY_API_URL, SLY_API_KEY, keys, urls);
|
|
31
|
+
async function main() {
|
|
32
|
+
const transport = new StdioServerTransport();
|
|
33
|
+
await server.connect(transport);
|
|
34
|
+
console.error("Sly MCP server running on stdio");
|
|
35
|
+
console.error(`Environment: ${SLY_ENVIRONMENT}`);
|
|
36
|
+
}
|
|
37
|
+
main().catch((error) => {
|
|
38
|
+
console.error("Fatal error:", error);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
});
|
|
41
|
+
export {
|
|
42
|
+
createMcpServer,
|
|
43
|
+
tools
|
|
44
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { Sly } from '@sly/sdk';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* MCP Server Factory
|
|
6
|
+
*
|
|
7
|
+
* Creates a configured MCP Server instance that can be connected
|
|
8
|
+
* to any transport (stdio, HTTP, etc.).
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Mutable runtime context for the MCP server.
|
|
13
|
+
* Allows switching environments (sandbox ↔ production) without restart.
|
|
14
|
+
*/
|
|
15
|
+
interface McpContext {
|
|
16
|
+
sly: Sly;
|
|
17
|
+
apiUrl: string;
|
|
18
|
+
apiKey: string;
|
|
19
|
+
environment: string;
|
|
20
|
+
keys: Record<string, string>;
|
|
21
|
+
urls: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create an MCP Server with all Sly tools registered.
|
|
25
|
+
*/
|
|
26
|
+
declare function createMcpServer(sly: Sly, apiUrl: string, apiKey: string, keys?: Record<string, string>, urls?: Record<string, string>): Server;
|
|
27
|
+
|
|
28
|
+
export { type McpContext, createMcpServer };
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* MCP Tool Definitions
|
|
5
|
+
*
|
|
6
|
+
* All Sly MCP tools extracted for reuse across transports
|
|
7
|
+
* (stdio for Claude Desktop, HTTP for remote clients like Intercom Fin).
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
declare const tools: Tool[];
|
|
11
|
+
|
|
12
|
+
export { tools };
|
package/dist/tools.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sly_ai/mcp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Model Context Protocol (MCP) server for Sly - enables Claude Desktop integration and remote HTTP access",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts"
|
|
12
|
+
},
|
|
13
|
+
"./tools": {
|
|
14
|
+
"import": "./dist/tools.js",
|
|
15
|
+
"types": "./dist/tools.d.ts"
|
|
16
|
+
},
|
|
17
|
+
"./server-factory": {
|
|
18
|
+
"import": "./dist/server-factory.js",
|
|
19
|
+
"types": "./dist/server-factory.d.ts"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"bin": {
|
|
23
|
+
"sly-mcp-server": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "tsup src/index.ts src/tools.ts src/server-factory.ts --format esm --dts --shims",
|
|
27
|
+
"dev": "tsup src/index.ts src/tools.ts src/server-factory.ts --format esm --dts --watch --shims",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"test": "vitest run",
|
|
30
|
+
"test:watch": "vitest",
|
|
31
|
+
"start": "node dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@sly/sdk": "workspace:*",
|
|
35
|
+
"@modelcontextprotocol/sdk": "^1.0.4"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^20.14.10",
|
|
39
|
+
"tsup": "^8.0.0",
|
|
40
|
+
"typescript": "^5.3.3",
|
|
41
|
+
"vitest": "^2.0.0"
|
|
42
|
+
},
|
|
43
|
+
"keywords": [
|
|
44
|
+
"mcp",
|
|
45
|
+
"model-context-protocol",
|
|
46
|
+
"claude",
|
|
47
|
+
"sly",
|
|
48
|
+
"payments",
|
|
49
|
+
"ai"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tests for MCP Server
|
|
3
|
+
* Note: These are basic tests. Full integration testing requires MCP Inspector.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, it, expect } from 'vitest';
|
|
7
|
+
|
|
8
|
+
describe('MCP Server', () => {
|
|
9
|
+
it('should be testable', () => {
|
|
10
|
+
// Basic smoke test
|
|
11
|
+
expect(true).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should have required environment variables documented', () => {
|
|
15
|
+
// Test that environment variables are documented
|
|
16
|
+
const requiredEnvVars = ['SLY_API_KEY', 'SLY_ENVIRONMENT'];
|
|
17
|
+
expect(requiredEnvVars).toHaveLength(2);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should define expected tools', () => {
|
|
21
|
+
const expectedTools = [
|
|
22
|
+
// Settlement
|
|
23
|
+
'get_settlement_quote',
|
|
24
|
+
'create_settlement',
|
|
25
|
+
'get_settlement_status',
|
|
26
|
+
// UCP Checkout
|
|
27
|
+
'ucp_discover',
|
|
28
|
+
'ucp_create_checkout',
|
|
29
|
+
'ucp_get_checkout',
|
|
30
|
+
'ucp_list_checkouts',
|
|
31
|
+
'ucp_update_checkout',
|
|
32
|
+
'ucp_complete_checkout',
|
|
33
|
+
'ucp_cancel_checkout',
|
|
34
|
+
'ucp_add_payment_instrument',
|
|
35
|
+
'ucp_batch_checkout',
|
|
36
|
+
// UCP Orders
|
|
37
|
+
'ucp_list_orders',
|
|
38
|
+
'ucp_get_order',
|
|
39
|
+
'ucp_update_order_status',
|
|
40
|
+
'ucp_cancel_order',
|
|
41
|
+
'ucp_add_fulfillment_event',
|
|
42
|
+
// Agent Management
|
|
43
|
+
'list_accounts',
|
|
44
|
+
'create_agent',
|
|
45
|
+
'verify_agent',
|
|
46
|
+
'get_agent',
|
|
47
|
+
'get_agent_limits',
|
|
48
|
+
// AP2 Mandates
|
|
49
|
+
'ap2_create_mandate',
|
|
50
|
+
'ap2_get_mandate',
|
|
51
|
+
'ap2_execute_mandate',
|
|
52
|
+
'ap2_list_mandates',
|
|
53
|
+
// ACP Checkouts
|
|
54
|
+
'acp_create_checkout',
|
|
55
|
+
'acp_get_checkout',
|
|
56
|
+
'acp_complete_checkout',
|
|
57
|
+
'acp_list_checkouts',
|
|
58
|
+
// Wallet Management
|
|
59
|
+
'list_wallets',
|
|
60
|
+
'create_wallet',
|
|
61
|
+
'get_wallet',
|
|
62
|
+
'get_wallet_balance',
|
|
63
|
+
'wallet_deposit',
|
|
64
|
+
'wallet_withdraw',
|
|
65
|
+
'wallet_test_fund',
|
|
66
|
+
// x402 Micropayments
|
|
67
|
+
'x402_create_endpoint',
|
|
68
|
+
'x402_list_endpoints',
|
|
69
|
+
'x402_get_endpoint',
|
|
70
|
+
'x402_pay',
|
|
71
|
+
'x402_verify',
|
|
72
|
+
];
|
|
73
|
+
expect(expectedTools).toHaveLength(42);
|
|
74
|
+
});
|
|
75
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Sly MCP Server — CLI Entry Point
|
|
5
|
+
*
|
|
6
|
+
* Model Context Protocol server for Claude Desktop integration.
|
|
7
|
+
* Exposes Sly payment capabilities as MCP tools via stdio transport.
|
|
8
|
+
*
|
|
9
|
+
* Usage:
|
|
10
|
+
* npx @sly/mcp-server
|
|
11
|
+
*
|
|
12
|
+
* Configuration via environment variables:
|
|
13
|
+
* SLY_API_KEY - Your Sly API key (required)
|
|
14
|
+
* SLY_ENVIRONMENT - 'sandbox' | 'testnet' | 'production' (default: 'sandbox')
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
18
|
+
import { Sly, getEnvironmentConfig } from '@sly/sdk';
|
|
19
|
+
import { createMcpServer } from './server-factory.js';
|
|
20
|
+
|
|
21
|
+
// Re-export for external consumers (e.g., apps/api remote MCP endpoint)
|
|
22
|
+
export { tools } from './tools.js';
|
|
23
|
+
export { createMcpServer } from './server-factory.js';
|
|
24
|
+
export type { McpContext } from './server-factory.js';
|
|
25
|
+
|
|
26
|
+
// Get configuration from environment
|
|
27
|
+
const SLY_API_KEY = process.env.SLY_API_KEY;
|
|
28
|
+
const SLY_API_KEY_LIVE = process.env.SLY_API_KEY_LIVE;
|
|
29
|
+
const SLY_ENVIRONMENT = (process.env.SLY_ENVIRONMENT as 'sandbox' | 'testnet' | 'production') || 'sandbox';
|
|
30
|
+
|
|
31
|
+
if (!SLY_API_KEY) {
|
|
32
|
+
console.error('Error: SLY_API_KEY environment variable is required');
|
|
33
|
+
process.exit(1);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Initialize Sly SDK
|
|
37
|
+
const sly = new Sly({
|
|
38
|
+
apiKey: SLY_API_KEY,
|
|
39
|
+
environment: SLY_ENVIRONMENT,
|
|
40
|
+
apiUrl: process.env.SLY_API_URL,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Derive API URL for direct fetch calls (batch operations)
|
|
44
|
+
const SLY_API_URL = process.env.SLY_API_URL || getEnvironmentConfig(SLY_ENVIRONMENT).apiUrl;
|
|
45
|
+
|
|
46
|
+
// Build keys map for runtime environment switching
|
|
47
|
+
const keys: Record<string, string> = { sandbox: SLY_API_KEY };
|
|
48
|
+
if (SLY_API_KEY_LIVE) keys.production = SLY_API_KEY_LIVE;
|
|
49
|
+
|
|
50
|
+
// Build URLs map for runtime environment switching
|
|
51
|
+
const SLY_API_URL_LIVE = process.env.SLY_API_URL_LIVE;
|
|
52
|
+
const urls: Record<string, string> = { sandbox: SLY_API_URL };
|
|
53
|
+
if (SLY_API_URL_LIVE) urls.production = SLY_API_URL_LIVE;
|
|
54
|
+
|
|
55
|
+
// Create MCP server with all tools
|
|
56
|
+
const server = createMcpServer(sly, SLY_API_URL, SLY_API_KEY, keys, urls);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Start the server
|
|
60
|
+
*/
|
|
61
|
+
async function main() {
|
|
62
|
+
const transport = new StdioServerTransport();
|
|
63
|
+
await server.connect(transport);
|
|
64
|
+
|
|
65
|
+
console.error('Sly MCP server running on stdio');
|
|
66
|
+
console.error(`Environment: ${SLY_ENVIRONMENT}`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
main().catch((error) => {
|
|
70
|
+
console.error('Fatal error:', error);
|
|
71
|
+
process.exit(1);
|
|
72
|
+
});
|