bsv-mcp 0.3.0 โ†’ 0.3.2

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.
@@ -1,179 +0,0 @@
1
- #!/usr/bin/env bun
2
- import { Client } from "@modelcontextprotocol/sdk/client/index.js";
3
- import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
4
-
5
- /**
6
- * Read the first text block out of a callTool result. The client return type
7
- * is a union that also covers the legacy `toolResult` shape, so the content
8
- * array has to be checked rather than assumed.
9
- */
10
- function firstText(result: { [key: string]: unknown }): string {
11
- const content = result.content;
12
- if (!Array.isArray(content) || content.length === 0) {
13
- throw new Error("Tool result carried no content blocks");
14
- }
15
- const block: unknown = content[0];
16
- if (
17
- typeof block !== "object" ||
18
- block === null ||
19
- !("text" in block) ||
20
- typeof block.text !== "string"
21
- ) {
22
- throw new Error("First content block was not text");
23
- }
24
- return block.text;
25
- }
26
-
27
- async function testMCPServer() {
28
- console.log("๐Ÿงช Testing BSV MCP Server...\n");
29
-
30
- // Create transport
31
- const transport = new StdioClientTransport({
32
- command: "bun",
33
- args: ["run", "./index.ts"],
34
- env: {
35
- ...process.env,
36
- TRANSPORT: "stdio",
37
- DISABLE_BROADCASTING: "true", // Don't broadcast test transactions
38
- USE_DROPLET_API: "false", // Use local mode to test BSocial
39
- },
40
- });
41
-
42
- // Create client
43
- const client = new Client(
44
- { name: "test-client", version: "1.0.0" },
45
- {
46
- capabilities: {},
47
- },
48
- );
49
-
50
- try {
51
- // Connect
52
- console.log("๐Ÿ“ก Connecting to server...");
53
- await client.connect(transport);
54
- console.log("โœ… Connected successfully\n");
55
-
56
- // List available tools
57
- console.log("๐Ÿ”ง Available tools:");
58
- const tools = await client.listTools();
59
- console.log(`Found ${tools.tools.length} tools:`);
60
-
61
- // Group tools by category
62
- const categories = new Map<string, string[]>();
63
- for (const tool of tools.tools) {
64
- const prefix = tool.name.split("_")[0];
65
- if (!categories.has(prefix)) {
66
- categories.set(prefix, []);
67
- }
68
- const categoryTools = categories.get(prefix);
69
- if (categoryTools) {
70
- categoryTools.push(tool.name);
71
- }
72
- }
73
-
74
- // Display by category
75
- for (const [category, toolNames] of categories) {
76
- console.log(`\n${category}:`);
77
- for (const name of toolNames) {
78
- console.log(` - ${name}`);
79
- }
80
- }
81
-
82
- // Test a few tools
83
- console.log("\n๐Ÿงช Testing tools:\n");
84
-
85
- // 1. Test BSV price tool
86
- console.log("1. Testing bsv_getPrice:");
87
- try {
88
- const priceResult = await client.callTool({
89
- name: "bsv_getPrice",
90
- arguments: {},
91
- });
92
- const content = { text: firstText(priceResult) };
93
- console.log("โœ…", content.text);
94
- } catch (error) {
95
- console.log("โŒ Error:", error);
96
- }
97
-
98
- // 2. Test utils conversion
99
- console.log("\n2. Testing utils_convertData:");
100
- try {
101
- const convertResult = await client.callTool({
102
- name: "utils_convertData",
103
- arguments: {
104
- args: {
105
- data: "Hello BSV!",
106
- from: "utf8",
107
- to: "hex",
108
- },
109
- },
110
- });
111
- const content = { text: firstText(convertResult) };
112
- console.log("โœ… Converted:", content.text);
113
- } catch (error) {
114
- console.log("โŒ Error:", error);
115
- }
116
-
117
- // 3. Test bsocial_readPosts
118
- console.log("\n3. Testing bsocial_readPosts:");
119
- try {
120
- const postsResult = await client.callTool({
121
- name: "bsocial_readPosts",
122
- arguments: {
123
- args: {
124
- limit: 5,
125
- },
126
- },
127
- });
128
- const content = { text: firstText(postsResult) };
129
- console.log("โœ… Read posts (showing first 200 chars):");
130
- console.log(`${content.text.substring(0, 200)}...`);
131
- } catch (error) {
132
- console.log("โŒ Error:", error);
133
- }
134
-
135
- // 4. Test ordinals search
136
- console.log("\n4. Testing ordinals_searchInscriptions:");
137
- try {
138
- const ordinalsResult = await client.callTool({
139
- name: "ordinals_searchInscriptions",
140
- arguments: {
141
- args: {
142
- query: "test",
143
- limit: 3,
144
- },
145
- },
146
- });
147
- const content = { text: firstText(ordinalsResult) };
148
- const response = JSON.parse(content.text);
149
- console.log(`โœ… Found ${response.total || 0} inscriptions`);
150
- } catch (error) {
151
- console.log("โŒ Error:", error);
152
- }
153
-
154
- // List resources
155
- console.log("\n๐Ÿ“š Available resources:");
156
- const resources = await client.listResources();
157
- console.log(`Found ${resources.resources.length} resources`);
158
- for (const resource of resources.resources) {
159
- console.log(` - ${resource.name}`);
160
- }
161
-
162
- // List prompts
163
- console.log("\n๐Ÿ’ญ Available prompts:");
164
- const prompts = await client.listPrompts();
165
- console.log(`Found ${prompts.prompts.length} prompts`);
166
- for (const prompt of prompts.prompts) {
167
- console.log(` - ${prompt.name}`);
168
- }
169
- } catch (error) {
170
- console.error("โŒ Test failed:", error);
171
- } finally {
172
- console.log("\n๐Ÿ”Œ Disconnecting...");
173
- await client.close();
174
- process.exit(0);
175
- }
176
- }
177
-
178
- // Run the test
179
- testMCPServer().catch(console.error);