1.0.0-SNAPSHOT

@Bean
    ChatClient tongYiWithMcp() {
        ChatClient.Builder builder = ChatClient.builder(
                        OpenAiChatModel.builder().openAiApi(
                                        OpenAiApi.builder()
                                                .baseUrl("https://dashscope.aliyuncs.com/compatible-mode/v1")
                                                .completionsPath("/chat/completions")
                                                .embeddingsPath("/embeddings")
                                                .apiKey("")
                                                .build())
                                .build())
                .defaultOptions(
                        ChatOptions.builder().model("qwen-max").build())
                .defaultToolCallbacks(toolCallbackProvider)
                .defaultAdvisors(new SimpleLoggerAdvisor());
        return builder.build();
    }

I configure the client according to the above code I saw that the tool was obtained normally But the tool is not called. For the same model and MCP, you can use tool with cherry How should I do it?

2025-05-16 23:15:25 [pool-5-thread-1] INFO  i.m.c.transport.StdioClientTransport - STDERR Message received: 2025-05-16 23:15:25 - mcp.server.lowlevel.server - INFO - Processing request of type ListToolsRequest
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_historical_k_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_stock_basic_info 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_dividend_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_adjust_factor_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_profit_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_operation_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_growth_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_balance_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_cash_flow_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_dupont_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_performance_express_report 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_forecast_report 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_stock_industry 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_sz50_stocks 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_hs300_stocks 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_zz500_stocks 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_trade_dates 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_all_stock 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_deposit_rate_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_loan_rate_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_required_reserve_ratio_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_money_supply_data_month 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_money_supply_data_year 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_shibor_data 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_latest_trading_date 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_market_analysis_timeframe 
2025-05-16 23:15:25 [main] INFO  c.lxy.invest.service.AShareService - Tool:get_stock_analysis 

Comment From: Ador-able

@Bean
    public ChatClient tongYiWithMcp2(ChatClient.Builder chatClientBuilder, List<McpSyncClient> mcpSyncClients) {

        return chatClientBuilder
                    .defaultToolCallbacks(new SyncMcpToolCallbackProvider(mcpSyncClients))
                    .defaultAdvisors(new SimpleLoggerAdvisor(),MessageChatMemoryAdvisor.builder(MessageWindowChatMemory.builder().build()).build())
                    .build();

    }

If I write this, I can call mcp tools. But some of my models have addresses https://ark.cn-beijing.volces.com/api/v3/. Openaichatmodel has a fixed v1 inside. As a result, I can only configure myself, how should I modify it to call mcp tools

Comment From: markpollack

In your first eample, it is not clear how toolCallbackProvider is being created.

Openaichatmodel does not have a fixed v1 in it, defaults are in the OpenAiApi class.

The baseUrl should only include the scheme and host (e.g., https://dashscope.aliyuncs.com). The full API path, including any version segment like /v1 or /compatible-mode/v1, should go in the completionsPath.

hope this helps.

Comment From: Ador-able

After deleting DefaultOptions, it can be executed normally. Although I don't know why, this problem can be closed