MCPcopy Create free account
hub / github.com/echoVic/blade-code / networkToolsExample

Function networkToolsExample

examples/tools-example.ts:150–197  ·  view source on GitHub ↗

* 网络工具示例

()

Source from the content-addressed store, hash-verified

148 * 网络工具示例
149 */
150async function networkToolsExample() {
151 console.log('=== 网络工具示例 ===\n');
152
153 const toolManager = await createToolManager();
154
155 // URL 解析
156 console.log('1. URL 解析:');
157 const urlParseResult = await toolManager.callTool({
158 toolName: 'url_parse',
159 parameters: {
160 url: 'https://api.example.com:8080/v1/users?page=1&limit=10#section1',
161 },
162 });
163 console.log('结果:', JSON.stringify(urlParseResult.result.data, null, 2));
164 console.log('');
165
166 // URL 构建
167 console.log('2. URL 构建:');
168 const urlBuildResult = await toolManager.callTool({
169 toolName: 'url_build',
170 parameters: {
171 protocol: 'https',
172 hostname: 'api.example.com',
173 port: 443,
174 pathname: '/v1/users',
175 queryParams: {
176 page: 1,
177 limit: 10,
178 },
179 hash: 'results',
180 },
181 });
182 console.log('结果:', JSON.stringify(urlBuildResult.result.data, null, 2));
183 console.log('');
184
185 // JSON 格式化
186 console.log('3. JSON 格式化:');
187 const jsonFormatResult = await toolManager.callTool({
188 toolName: 'json_format',
189 parameters: {
190 input: '{"name":"John","age":30,"city":"New York"}',
191 operation: 'format',
192 indent: 2,
193 },
194 });
195 console.log('结果:', JSON.stringify(jsonFormatResult.result.data, null, 2));
196 console.log('');
197}
198
199/**
200 * 自定义工具示例

Callers 1

mainFunction · 0.85

Calls 3

createToolManagerFunction · 0.85
logMethod · 0.45
callToolMethod · 0.45

Tested by

no test coverage detected