diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-06-30 19:03:25 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-06-30 19:03:25 +0900 |
| commit | 05c8e0a31a0d4192c590e833b24393208e1c751f (patch) | |
| tree | f7c2c82c9327abde67bf3acf1d0258573b3bc6c2 /tests/mcpc_test.c | |
| parent | 4bc721c3bf7589b519c5730d093f704ce56e3f09 (diff) | |
fix: MCPCをvendored fork化しMCP準拠と接続安定性を改善
- Git submoduleを廃止してMCPCを直接管理
- Windowsで254リクエスト付近に発生する切断を修正
- JSON-RPC 2.0エラー応答を標準化
- tool schemaとruntimeの必須・任意引数を一致
- 1000回連続呼び出しの回帰テストを追加
Diffstat (limited to 'tests/mcpc_test.c')
| -rw-r--r-- | tests/mcpc_test.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/mcpc_test.c b/tests/mcpc_test.c new file mode 100644 index 0000000..b0d317e --- /dev/null +++ b/tests/mcpc_test.c @@ -0,0 +1,41 @@ +#include <mcpc/mcpc.h> + +#include <stdio.h> + +#include "support/test.h" + +static void +empty_callback(const mcpc_tool_t *tool, mcpc_ucbr_t *result) +{ + (void)tool; + mcpc_toolcall_result_add_text_printf8(result, (const char8_t *)"{}"); +} + +int +main(void) +{ + tiny_test_state_t state = { "mcpc fork", 0, 0 }; + FILE *input = tmpfile(); + FILE *output = tmpfile(); + mcpc_server_t *server; + mcpc_tool_t *tool; + mcpc_toolprop_t *property; + TINY_EXPECT(&state, input != NULL && output != NULL); + server = mcpc_server_new_iostrm(input, output); + TINY_EXPECT(&state, server != NULL); + tool = mcpc_tool_new2((const char8_t *)"test", (const char8_t *)"test tool"); + TINY_EXPECT(&state, tool != NULL); + TINY_EXPECT(&state, mcpc_server_add_tool(server, tool) == MCPC_EC_BUG); + TINY_EXPECT(&state, mcpc_tool_set_call_cb(tool, empty_callback) == MCPC_EC_0); + + property = mcpc_toolprop_new2((const char8_t *)"limit", (const char8_t *)"limit", MCPC_I32); + TINY_EXPECT(&state, property != NULL && mcpc_toolprop_is_required(property)); + TINY_EXPECT(&state, mcpc_toolprop_set_required(property, false) == MCPC_EC_0); + TINY_EXPECT(&state, !mcpc_toolprop_is_required(property)); + mcpc_tool_add_toolprop(tool, property); + TINY_EXPECT(&state, mcpc_server_add_tool(server, tool) == MCPC_EC_0); + TINY_EXPECT(&state, mcpc_server_close(server) == MCPC_EC_0); + fclose(input); + fclose(output); + return tiny_test_finish(&state); +} |
