Content
# MCP Server
## Introduction
[面试鸭](https://mianshiya.com/)
's question search API is now compatible with the MCP protocol, making it the first interview question brushing website in China to be compatible with the MCP protocol. For more information about the MCP protocol, see the official MCP [documentation](https://modelcontextprotocol.io/).
Developed based on the `MCP Java SDK`, any intelligent assistant that supports the MCP protocol (such as `Claude`, `Cursor`, and `千帆AppBuilder`, etc.) can be quickly integrated.
The following will provide more detailed adaptation instructions.
## Tool List
#### Question Search `questionSearch`
- Retrieve interview questions as question links in 面试鸭
- Input: `题目`
- Output: `[题目](链接)`
## Quick Start
Using the MCP Server mainly through the form of `Java SDK`
### Java Access
> Requires Java 17 runtime environment
#### Installation
``` bash
git clone https://github.com/yuyuanweb/mcp-mianshiya-server
```
#### Build
``` bash
cd mcp-mianshiya-server
mvn clean package
```
#### Usage
1) Open `Cherry Studio`'s `Settings` and click `MCP Server`.
<img src="img/cherry1.png" alt="cherry1.png">
2) Click `Edit JSON` and add the following configuration to the configuration file.
``` 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": {}
}
}
}
```
<img src="img/cherry2.png" alt="cherry2.png">
3) In Settings - Model Service, select a model, enter the API key, select model settings, and check the tool function call feature.
<img src="img/cherry3.png" alt="cherry3.png">
4) Check to enable the MCP service below the input box.
<img src="img/cherry4.png" alt="cherry4.png">
5) Configuration is complete, then query the following interview questions
<img src="img/cherry5.png" alt="cherry5.png">
#### Code Call
1) Introduce dependencies
``` java
<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) Configure the MCP server
You need to configure some parameters of the MCP server in application.yml:
``` yaml
spring:
ai:
mcp:
client:
stdio:
# Specify the MCP server configuration file
servers-configuration: classpath:/mcp-servers-config.json
mandatory-file-encoding: UTF-8
```
The configuration of mcp-servers-config.json is as follows:
``` json
{
"mcpServers": {
"mianshiyaServer": {
"command": "java",
"args": [
"-Dspring.ai.mcp.server.stdio=true",
"-Dspring.main.web-application-type=none",
"-Dlogging.pattern.console=",
"-jar",
"/Users/gulihua/Documents/mcp-server/target/mcp-server-0.0.1-SNAPSHOT.jar"
],
"env": {}
}
}
}
```
We use Alibaba's 通义千问 model for the client, so we introduce the spring-ai-alibaba-starter dependency. If you are using other models, you can also use the corresponding dependencies, such as openAI introducing the `spring-ai-openai-spring-boot-starter` dependency.
Configure the key and other information of the large model:
``` yaml
spring:
ai:
dashscope:
api-key: ${通义千问的key}
chat:
options:
model: qwen-max
```
The key of 通义千问 can be directly applied for on the [official website](https://help.aliyun.com/zh/model-studio/developer-reference/get-api-key?spm=a2c4g.11186623.0.0.7399482394LUBH). We use 通义千问-Max for the model.
3) Initialize the chat client
``` java
@Bean
public ChatClient initChatClient(ChatClient.Builder chatClientBuilder,
ToolCallbackProvider mcpTools) {
return chatClientBuilder
.defaultTools(mcpTools)
.build();
}
```
4) Interface call
``` java
@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]"));
}
```
Connection Info
You Might Also Like
awesome-mcp-servers
A collection of MCP servers.
git
A Model Context Protocol server for Git automation and interaction.
Appwrite
Build like a team of hundreds
TrendRadar
TrendRadar: Your hotspot assistant for real news in just 30 seconds.
oh-my-opencode
Background agents · Curated agents like oracle, librarians, frontend...
chatbox
User-friendly Desktop Client App for AI Models/LLMs (GPT, Claude, Gemini, Ollama...)