MianshiyaServer

MianshiyaServer

未知

面试鸭 MCP 服务器 - 快速开始指南

简介

面试鸭 提供了兼容 MCP 协议的题目搜索 API,是国内首家兼容 MCP 协议 的面试刷题网站。通过 MCP 协议,任何兼容的智能体助手(如 Claude、Cursor、千帆AppBuilder 等)都能快速接入。

支持的工具

  • 题目搜索 (questionSearch):将面试题目检索为面试鸭里的题目链接

快速开始

使用 Cherry Studio 接入

  1. 克隆并构建项目

    git clone https://github.com/gulihua10010/mcp-mianshiya-server
    cd mcp-mianshiya-server
    mvn clean package
    
  2. 配置 Cherry Studio

    • 打开 Cherry Studio 的设置MCP 服务器
    • 点击编辑 JSON,添加以下配置(注意修改 jar 路径):
      {
        "mcpServers": {
          "mianshiyaServer": {
            "command": "java",
            "args": [
              "-Dspring.ai.mcp.server.stdio=true",
              "-Dspring.main.web-application-type=none",
              "-Dlogging.pattern.console=",
              "-jar",
              "/yourPath/mcp-server-0.0.1-SNAPSHOT.jar"
            ],
            "env": {}
          }
        }
      }
      
  3. 启用工具函数调用

    • 设置-模型服务中选择模型并输入 API 密钥
    • 勾选工具函数调用功能
    • 在输入框下方勾选开启 MCP 服务
  4. 开始使用

    • 现在你可以查询面试题目了

代码集成

  1. 添加依赖

    <dependency>
        <groupId>com.alibaba.cloud.ai</groupId>
        <artifactId>spring-ai-alibaba-starter</artifactId>
        <version>1.0.0-M6.1</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.ai</groupId>
        <artifactId>spring-ai-mcp-client-spring-boot-starter</artifactId>
        <version>1.0.0-M6</version>
    </dependency>
    
  2. 配置 MCP 服务器

    application.yml 中添加:

    spring:
      ai:
        mcp:
          client:
            stdio:
              servers-configuration: classpath:/mcp-servers-config.json
        dashscope:
          api-key: ${通义千问的key}
          chat:
            options:
              model: qwen-max
    mandatory-file-encoding: UTF-8
    

    创建 mcp-servers-config.json:

    {
      "mcpServers": {
        "mianshiyaServer": {
          "command": "java",
          "args": [
            "-Dspring.ai.mcp.server.stdio=true",
            "-Dspring.main.web-application-type=none",
            "-Dlogging.pattern.console=",
            "-jar",
            "/yourPath/mcp-server-0.0.1-SNAPSHOT.jar"
          ],
          "env": {}
        }
      }
    }
    
  3. 初始化聊天客户端

    @Bean
    public ChatClient initChatClient(ChatClient.Builder chatClientBuilder,
                                   ToolCallbackProvider mcpTools) {
        return chatClientBuilder
                .defaultTools(mcpTools)
                .build();
    }
    
  4. 实现接口调用

    @PostMapping(value = "/ai/answer/sse", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
    public Flux<String> generateStreamAsString(@RequestBody AskRequest request) {
        Flux<String> content = chatClient.prompt()
                .user(request.getContent())
                .stream()
                .content();
        return content
                .concatWith(Flux.just("[complete]"));
    }
    

注:通义千问的 API key 可在官网申请