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

Function textProcessingExample

examples/tools-example.ts:46–87  ·  view source on GitHub ↗

* 文本处理工具示例

()

Source from the content-addressed store, hash-verified

44 * 文本处理工具示例
45 */
46async function textProcessingExample() {
47 console.log('=== 文本处理工具示例 ===\n');
48
49 const toolManager = await createToolManager();
50
51 // 文本长度统计
52 console.log('1. 文本长度统计:');
53 const lengthResult = await toolManager.callTool({
54 toolName: 'text_length',
55 parameters: {
56 text: 'Hello, 世界!This is a test string.\nSecond line.',
57 countType: 'all',
58 },
59 });
60 console.log('结果:', JSON.stringify(lengthResult.result.data, null, 2));
61 console.log('');
62
63 // 文本格式化
64 console.log('2. 文本格式化:');
65 const formatResult = await toolManager.callTool({
66 toolName: 'text_format',
67 parameters: {
68 text: ' hello world ',
69 operation: 'trim',
70 },
71 });
72 console.log('结果:', JSON.stringify(formatResult.result.data, null, 2));
73 console.log('');
74
75 // 文本搜索
76 console.log('3. 文本搜索:');
77 const searchResult = await toolManager.callTool({
78 toolName: 'text_search',
79 parameters: {
80 text: 'The quick brown fox jumps over the lazy dog.',
81 pattern: 'o',
82 caseSensitive: false,
83 },
84 });
85 console.log('结果:', JSON.stringify(searchResult.result.data, null, 2));
86 console.log('');
87}
88
89/**
90 * 实用工具示例

Callers 1

mainFunction · 0.85

Calls 3

createToolManagerFunction · 0.85
logMethod · 0.45
callToolMethod · 0.45

Tested by

no test coverage detected