Skip to content

Support MCP( WIP) #5974

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
Jan 19, 2025
Merged

Support MCP( WIP) #5974

merged 31 commits into from
Jan 19, 2025

Conversation

Leizhenpeng
Copy link
Member

@Leizhenpeng Leizhenpeng commented Dec 23, 2024

💻 变更类型 | Change Type

  • feat
  • fix
  • refactor
  • perf
  • style
  • test
  • docs
  • ci
  • chore
  • build

🔀 变更说明 | Description of Change

📝 补充信息 | Additional Information

Summary by CodeRabbit

Release Notes

  • New Features

    • Added Multi-Channel Protocol (MCP) support with server management capabilities.
    • Introduced MCP Market for discovering and configuring AI service clients.
    • Enhanced chat functionality with MCP tool integration.
    • Implemented a new component for managing MCP servers with dynamic configuration options.
  • Model Support

    • Updated supported AI models to include Claude, GPT-4, and Gemini Pro.
  • User Interface

    • Added new sidebar icon for accessing MCP Market.
    • Enhanced message rendering logic in the chat component.
    • Introduced loading indicators and error notifications for server operations.
  • Performance

    • Improved client initialization and management processes.
    • Added robust error handling for MCP system operations.
  • Documentation

    • Updated Chinese README to reflect new model support.
    • Expanded localization to include MCP terminology in English and Chinese.
    • Introduced a new optional environment variable for enabling MCP functionality.
  • Chores

    • Added new constants and updated existing enums for better organization.
    • Implemented logging enhancements for better tracking of MCP operations.
    • Added a new entry to .gitignore for mcp_config.json.

Copy link

vercel bot commented Dec 23, 2024

Deployment failed with the following error:

You don't have permission to create a Preview Deployment for this project.

View Documentation: https://vercel.com/docs/accounts/team-members-and-roles

Copy link
Contributor

coderabbitai bot commented Dec 23, 2024

Walkthrough

This pull request introduces a comprehensive implementation of the Multi-Channel Protocol (MCP) system for NextChat. The changes span multiple files, adding new functionality for managing multiple AI clients, server configurations, and a dedicated market page for MCP servers. The implementation includes client management, logging, configuration handling, and a new user interface component for exploring and configuring MCP servers.

Changes

File Change Summary
README_CN.md Updated supported models from GPT3 to Claude and added ENABLE_MCP environment variable documentation.
app/mcp/actions.ts Added comprehensive MCP client management functions including status retrieval, server management, and error handling.
app/mcp/client.ts Implemented client creation, removal, and request execution functions.
app/mcp/logger.ts Created a new logging class for MCP client operations with various log levels.
app/store/chat.ts Enhanced message processing with MCP support, including new methods for handling MCP responses.
package.json Added MCP-related dependencies and updated scripts for application management.
app/components/home.tsx, app/components/sidebar.tsx Integrated MCP market navigation and initialization of MCP status checking.
app/constant.ts Added MCP-related templates and updated path/store keys.
app/locales/cn.ts, app/locales/en.ts Added new localization entry for MCP.
.gitignore, .eslintignore Added entry to ignore mcp_config.json.
tsconfig.json Updated TypeScript target and modified included files.
app/mcp/utils.ts Added functions for MCP JSON handling to check and extract MCP data.
app/mcp/types.ts Introduced new interfaces and schemas for MCP messages and server configurations.
app/components/chat.tsx Enhanced chat message rendering logic with MCP features and added a new component for MCP actions.
app/components/mcp-market.tsx Created MCP Market component for server management and configuration.
app/components/mcp-market.module.scss Added styles for MCP Market component.
Dockerfile Introduced environment variable for MCP and updated file management steps.
app/config/server.ts Added MCP environment variable and updated server config retrieval logic.

Sequence Diagram

sequenceDiagram
    participant User
    participant McpMarketPage
    participant McpActions
    participant McpClient
    
    User->>McpMarketPage: Open MCP Market
    McpMarketPage->>McpActions: Get MCP Config
    McpActions-->>McpMarketPage: Return Config
    User->>McpMarketPage: Add New Server
    McpMarketPage->>McpActions: Add MCP Server
    McpActions->>McpClient: Initialize Client
    McpClient-->>McpActions: Client Created
    McpActions-->>McpMarketPage: Server Added
Loading

Poem

🐰 In the realm of chat, a new protocol springs,
MCP dances, and innovation sings!
Servers connect, tools unfurl with grace,
A rabbit's dream of AI's embrace! 🤖
Hop along the multi-channel way! 🚀

Finishing Touches

  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

Your build has completed!

Preview deployment

Copy link

vercel bot commented Dec 28, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextchat ❌ Failed (Inspect) Jan 19, 2025 3:28pm

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (9)
app/store/chat.ts (1)

429-447: Validate JSON parsing & protect against malformed message content

  • The regular expression approach to identify ```json:mcp blocks is functional, but consider graceful fallbacks if the block is missing or incomplete.
  • You already catch JSON parsing errors, which is good. In case of invalid JSON from user-provided data, ensuring a user-facing error response could be beneficial.
  • If multiple MCP calls can happen concurrently, verify the system’s concurrency handling to avoid race conditions.
app/mcp/actions.ts (1)

1-33: Leverage stronger typing and ensure concurrency safety

  • Currently, fsClient is typed as any—consider adding an explicit interface or type to make maintenance easier and reduce accidental misuse.
  • When multiple calls happen in quick succession, ensure initFileSystemClient can safely handle simultaneous initialization requests.
app/mcp/logger.ts (1)

1-60: Ensure cross-platform log compatibility

  • ANSI color codes might not display as intended across all terminals (e.g., some CI/CD environments or Windows shells).
  • Consider adding timestamps or structured logging for easier troubleshooting and correlation with other logs.
app/mcp/client.ts (4)

1-5: Use absolute imports selectively.

Imports from the "@modelcontextprotocol" package and Zod library are fine. However, ensure that these external imports remain minimal for faster builds and better maintainability. If future code only requires submodules, consider selective imports from large packages (e.g., import { ... } from "@modelcontextprotocol/sdk/client").


6-10: Clarify optional fields in ServerConfig interface.

Currently, args and env are optional. Provide doc comments describing the scenarios in which these fields would be omitted to improve code clarity.


44-47: Validate Primitive structure and values.

As Primitive.value is typed to any, adding a Zod schema or another validation layer for resource, tool, or prompt objects can improve type safety and help catch unexpected data structures from the server.


83-87: Use structured logging for request execution.

Currently, you only do console.log(r) after executing the request. Consider using logger.info or a more structured approach to log request/response pairs for debugging and auditing.

  ...
  const r = client.request(request, z.any());
- console.log(r);
+ logger.info("Request response:", r);
  return r;
}
tsconfig.json (1)

26-26: Cleanup references to removed files in include.

Removing "app/calcTextareaHeight.ts" from the include array is fine. Ensure that all references (e.g., imports) to that file are also removed throughout the codebase to avoid confusion.

package.json (1)

25-25: Leverage the @modelcontextprotocol/sdk dependency effectively.

Ensure that all relevant modules from the new SDK are utilized. If only a small subset is needed, consider partial imports or code splitting to reduce bundle size.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1c7c54 and c3108ad.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (9)
  • app/mcp/actions.ts (1 hunks)
  • app/mcp/client.ts (1 hunks)
  • app/mcp/example.ts (1 hunks)
  • app/mcp/logger.ts (1 hunks)
  • app/mcp/mcp_config.ts (1 hunks)
  • app/store/chat.ts (2 hunks)
  • next.config.mjs (3 hunks)
  • package.json (2 hunks)
  • tsconfig.json (2 hunks)
🔇 Additional comments (8)
app/store/chat.ts (1)

32-32: Add test coverage for 'executeMcpAction' usage

The new import integrates MCP action processing into the chat flow. To reduce the risk of unhandled edge cases (e.g., unavailable server, invalid JSON structures, etc.), please ensure the code path invoking executeMcpAction is tested thoroughly.

app/mcp/mcp_config.ts (1)

1-40: Secure storage of credentials and externalize paths

  • The placeholders for API keys and tokens should never be replaced by real secrets in the repository; instead, reading from environment variables or a vault is recommended.
  • The path "/Users/kadxy/Desktop" is hard-coded. Consider making this path configurable for different environments.
app/mcp/example.ts (1)

1-92: Harden the file reading mechanism

  • The code showcases reading arbitrary files from a specified path. Confirm that server-side controls or directory whitelisting is in place to guard against unauthorized access.
  • Good job using Zod schemas for validation—this helps ensure the integrity of server responses.
app/mcp/client.ts (1)

49-81: Parallel asynchronous operations are well handled; keep an eye on performance.

The approach of collecting promises in an array and awaiting them simultaneously is a good practice. For large-scale data, ensure the server handles concurrent calls effectively to avoid resource contention or throttling.

next.config.mjs (2)

35-35: Ensure experimental features are stable enough for production.

serverActions: true is an experimental feature. Confirm that your production environment accepts potential breaking changes or instabilities. Consider adding a feature gate or fallback logic.


75-78: Maintain consistent pattern for rewrite placeholders.

Rewrite placeholders, such as :resource_name and :deploy_name, are used in the destination URL. Confirm that you handle all edge cases (like missing or invalid resource_name / deploy_name). Potentially add server-side validation to avoid runtime errors.

tsconfig.json (1)

3-3: Check compatibility of ES2022 target.

Confirm that your deployment environment supports ES2022 features, or use a transpilation step if targeting older browsers. Some hosting platforms may not yet fully support ES2022 natively.

package.json (1)

57-58: Check versions & synergy for zod and zustand.

zod is now widely used for schema validation. Keep an eye on potential conflicts when using zustand for state management if any store-based validations are needed.

Comment on lines 14 to 42
export async function createClient(
serverConfig: ServerConfig,
name: string,
): Promise<Client> {
logger.info(`Creating client for server ${name}`);

const transport = new StdioClientTransport({
command: serverConfig.command,
args: serverConfig.args,
env: serverConfig.env,
});
const client = new Client(
{
name: `nextchat-mcp-client-${name}`,
version: "1.0.0",
},
{
capabilities: {
roots: {
// listChanged indicates whether the client will emit notifications when the list of roots changes.
// listChanged 指示客户端在根列表更改时是否发出通知。
listChanged: true,
},
},
},
);
await client.connect(transport);
return client;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider robust error handling for client creation.

When creating the client and connecting to the transport (line 40), include error handling for potential failures (e.g., invalid command, environment issues). This ensures unexpected errors are caught gracefully.

  ...
  await client.connect(transport);
+ // TODO: Consider wrapping this in try/catch:
+ // try {
+ //   await client.connect(transport);
+ // } catch (err) {
+ //   logger.error('Failed to connect to transport', err);
+ //   throw err;
+ // }
  return client;
}

Committable suggestion skipped: line range outside the PR's diff.

@@ -49,11 +50,12 @@
"remark-breaks": "^3.0.2",
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1",
"rt-client": "https://github.com/Azure-Samples/aoai-realtime-audio-sdk/releases/download/js/v0.5.0/rt-client-0.5.0.tgz",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Warning: The rt-client dependency is actively used and cannot be removed

The rt-client package is an essential dependency that is actively used in the realtime chat functionality:

  • It's imported and used extensively in app/components/realtime-chat/realtime-chat.tsx
  • Core functionalities depend on it:
    • Real-time audio streaming and processing
    • Voice chat features
    • Server communication for real-time responses
    • Audio transcription and playback

Removing this dependency would break the real-time chat feature. The package should be kept unless there's a planned replacement or the real-time chat functionality is being removed.

🔗 Analysis chain

Confirm removal of the deprecated rt-client dependency.

Verify that no modules still rely on rt-client. Skipping this verification might lead to runtime errors if references remain.


Let me gather more information about the actual usage of rt-client in the code.


Let me check the actual usage in the realtime-chat.tsx file to understand if this is an active dependency.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Searching for references to rt-client in the codebase:
rg 'rt-client' -A 3 -B 3

Length of output: 2671


Script:

#!/bin/bash
# Check for imports and actual usage of rt-client in the realtime components
ast-grep --pattern 'import { $$$ } from "rt-client"'

# Check for any direct usage of rt-client package
rg -l 'new RTClient|RTClient\.' 

Length of output: 675


Script:

#!/bin/bash
# Check the implementation in realtime-chat.tsx
cat app/components/realtime-chat/realtime-chat.tsx

Length of output: 10998

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (12)
app/mcp/actions.ts (3)

7-17: Global variables and maps
Storing clients in a global Map and a global initialized flag may be problematic in multi-instance or serverless environments. Consider a more robust design (e.g., an initialization manager) if concurrency or horizontal scaling are required.


18-51: initializeMcpClients function

  1. Code loops over conf.mcpServers and initializes each client with proper logging.
  2. Catches errors and tracks failed clients in errorClients.
  3. Marks initialized = true to prevent reinitialization.
  4. Logs final status and available clients.
    This flow is user-friendly and understandable. Consider adding retries or fallback logic for partial initialization failures.

53-70: executeMcpAction function

  1. Fetches the client from clientsMap by ID and executes the request.
  2. Logs any execution errors and rethrows them.
    Consider returning a standardized error object for better client-side handling, especially if this function may be extended for user-facing error messages in the future.
app/store/chat.ts (2)

363-367: MCP check on new messages
Line 366 calls checkMcpJson whenever a new message arrives. This integration ensures automatic detection of MCP requests without additional code in the message pipeline. Be sure to handle potential performance impacts if message volume is very high.


773-798: checkMcpJson function

  1. Validates if message content matches MCP JSON format.
  2. On success, extracts the MCP payload and invokes executeMcpAction.
  3. Uses onUserInput to feed back results as a new message.
    This is a clean, modular approach. However, watch for large JSON payloads or malicious content. Consider adding rate-limits or size checks for production.
app/mcp/utils.ts (2)

1-3: isMcpJson function
Returns the match result of a regex. This function is concise but slightly at risk of returning null or array. Consider returning a boolean explicitly (!!content.match(...)) if you only need a truthy check.


5-11: extractMcpJson function
Captures clientId and parses JSON from the second capture group. The approach is straightforward. A try-catch block for JSON parsing (or an upfront validity check) might guard against syntax errors or maliciously malformed JSON.

app/page.tsx (1)

9-10: Await MCP initialization
Blocking initialization ensures MCP dependencies are ready before UI rendering. Ensure that this call won’t degrade page responsiveness for users if the initialization is slow. Consider deferring or parallelizing if needed.

app/mcp/logger.ts (1)

24-65: Logging methods

  1. Provides functions for info, success, error, warn, and debug with consistent output formatting.
  2. debug is controlled by a flag to prevent noisy logs.
  3. A structured formatMessage method safely handles objects.
    Well-structured, though consider a fallback or custom transport in production to integrate with external logging systems (e.g., Winston, Bunyan).
app/mcp/client.ts (3)

32-35: Document or remove commented capabilities configuration.

The commented capabilities configuration lacks explanation. Either document why it's preserved for future use or remove it if unnecessary.


28-28: Consider extracting version to a configuration constant.

The hardcoded version "1.0.0" should be moved to a configuration constant for better maintainability.

+const CLIENT_VERSION = "1.0.0";
 
 export async function createClient(
   serverConfig: ServerConfig,
   name: string,
 ): Promise<Client> {
   // ...
   const client = new Client(
     {
       name: `nextchat-mcp-client-${name}`,
-      version: "1.0.0",
+      version: CLIENT_VERSION,
     },
     // ...
   );

52-76: Refactor duplicate promise handling pattern.

The promise handling pattern is repeated for resources, tools, and prompts. Consider extracting this to a helper function.

+const createPrimitivePromise = (
+  client: Client,
+  type: Primitive["type"],
+  listFn: () => Promise<{ [key: string]: any[] }>
+) => {
+  return listFn().then((result) => {
+    const items = result[`${type}s`];
+    items.forEach((item) => primitives.push({ type, value: item }));
+  });
+};

 if (capabilities?.resources) {
-  promises.push(
-    client.listResources().then(({ resources }) => {
-      resources.forEach((item) =>
-        primitives.push({ type: "resource", value: item }),
-      );
-    }),
-  );
+  promises.push(createPrimitivePromise(client, "resource", () => client.listResources()));
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c3108ad and e1ba8f1.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (10)
  • .eslintignore (1 hunks)
  • app/mcp/actions.ts (1 hunks)
  • app/mcp/client.ts (1 hunks)
  • app/mcp/example.ts (1 hunks)
  • app/mcp/logger.ts (1 hunks)
  • app/mcp/mcp_config.json (1 hunks)
  • app/mcp/utils.ts (1 hunks)
  • app/page.tsx (1 hunks)
  • app/store/chat.ts (4 hunks)
  • package.json (3 hunks)
✅ Files skipped from review due to trivial changes (2)
  • .eslintignore
  • app/mcp/mcp_config.json
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/mcp/example.ts
  • package.json
🔇 Additional comments (10)
app/mcp/actions.ts (3)

1-2: Use of "use server" directive
These lines establish a server-only execution context. Be mindful of referencing browser-specific APIs in server files to avoid runtime errors.


3-6: Import dependencies
Imports for createClient, executeRequest, MCPClientLogger, and the JSON config look consistent with the intended usage. Ensure that underlying modules handle errors gracefully.


72-77: getAvailableClients function
Filters out clients that failed to initialize. This is straightforward and aligns with the error management strategy. Ensure future expansions remain in sync (e.g., re-checking previously error-prone clients).

app/store/chat.ts (2)

32-33: New MCP imports
Imports from mcp/actions and mcp/utils introduce the MCP functionality into the chat store. This is a logical location given the store’s role in handling messages.


434-434: Asynchronous onFinish callback
This line suggests the onFinish callback is asynchronous. Confirm that all references to onFinish handle promises and potential errors correctly to avoid unhandled promise rejections.

app/page.tsx (1)

4-4: Import initializeMcpClients
This sets up a new dependency on actions.ts. Verify that all required environment variables and config references are available at runtime.

app/mcp/logger.ts (2)

1-10: Color codes definition
Defines ANSI codes for styling the log output. Straightforward and correct for Node.js environments.


12-22: Logger constructor and fields
The prefix and debugMode options provide flexible logging. This is a neat approach for customizing logs.

app/mcp/client.ts (2)

1-10: LGTM! Well-structured imports and interface definition.

The ServerConfig interface is well-designed with appropriate optional parameters for args and env configuration.


14-40: Add error handling for client creation and connection.

The client creation process should include proper error handling for transport creation and connection failures.


interface Primitive {
type: "resource" | "tool" | "prompt";
value: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace 'any' type with a more specific type.

Using 'any' type reduces type safety. Consider defining specific types for resource, tool, and prompt values.

Comment on lines 81 to 84
/** Execute a request */
export async function executeRequest(client: Client, request: any) {
return client.request(request, z.any());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Improve request validation and error handling.

The current implementation has several concerns:

  1. Using z.any() bypasses the benefits of Zod's type validation
  2. No request validation before execution
  3. No error handling for failed requests

Consider implementing proper validation and error handling:

-export async function executeRequest(client: Client, request: any) {
-  return client.request(request, z.any());
+export async function executeRequest(client: Client, request: unknown) {
+  const requestSchema = z.object({
+    // Define your request schema here
+    // Example:
+    // method: z.string(),
+    // params: z.record(z.unknown())
+  });
+
+  try {
+    const validatedRequest = requestSchema.parse(request);
+    return await client.request(validatedRequest, z.unknown());
+  } catch (error) {
+    if (error instanceof z.ZodError) {
+      throw new Error(`Invalid request format: ${error.message}`);
+    }
+    throw error;
+  }
+}

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
app/store/chat.ts (2)

Line range hint 376-402: Enhance type safety in onUserInput function.

The function could benefit from improved type safety:

  1. The isMcpResponse parameter should have a default value since it's optional
  2. The content type assertion should be more explicit

Consider applying these changes:

  async onUserInput(
    content: string,
    attachImages?: string[],
-   isMcpResponse?: boolean,
+   isMcpResponse: boolean = false,
  ) {
    const session = get().currentSession();
    const modelConfig = session.mask.modelConfig;

-   let mContent: string | MultimodalContent[] = isMcpResponse
+   let mContent: string | MultimodalContent[] = isMcpResponse === true
      ? content
      : fillTemplateWith(content, modelConfig);

782-810: Enhance error handling and maintainability in checkMcpJson.

Consider the following improvements:

  1. Add specific error type handling
  2. Add debug logging for the response formatting
  3. Extract JSON response formatting to a separate function

Consider applying these changes:

  checkMcpJson(message: ChatMessage) {
    const content = getMessageTextContent(message);
    if (isMcpJson(content)) {
      try {
        const mcpRequest = extractMcpJson(content);
        if (mcpRequest) {
          console.debug("[MCP Request]", mcpRequest);

          executeMcpAction(mcpRequest.clientId, mcpRequest.mcp)
            .then((result) => {
              console.log("[MCP Response]", result);
-             const mcpResponse =
-               typeof result === "object"
-                 ? JSON.stringify(result)
-                 : String(result);
+             const mcpResponse = formatMcpResponse(result);
+             console.debug("[MCP Formatted Response]", mcpResponse);
              get().onUserInput(
                `\`\`\`json:mcp:${mcpRequest.clientId}\n${mcpResponse}\n\`\`\``,
                [],
                true,
              );
            })
-           .catch((error) => showToast(String(error)));
+           .catch((error) => {
+             console.error("[MCP Execution Error]", error);
+             showToast(error instanceof Error ? error.message : String(error));
+           });
        }
-     } catch (error) {
+     } catch (error: unknown) {
        console.error("[MCP Error]", error);
+       showToast("Failed to process MCP request");
      }
    }
  },

+ function formatMcpResponse(result: unknown): string {
+   return typeof result === "object" ? JSON.stringify(result) : String(result);
+ }
app/mcp/types.ts (2)

1-2: Optional: Confirm the specification link remains stable.

The comment references an external spec URL. If it’s crucial, ensure the link remains valid. If the spec is versioned, consider pinning a specific version for documentation stability.


21-32: Response interface structure is flexible and aligns well with standard JSON-RPC patterns.

The error structure is appropriately typed, ensuring systematic error reporting. Consider adding clearer distinction for success vs. error states if your logic requires it.

app/mcp/client.ts (2)

43-46: Primitive interface uses 'any'.

Using any type for value reduces type safety. Define a union or more explicit shape if the data is known.

-interface Primitive {
-  type: "resource" | "tool" | "prompt";
-  value: any;
-}
+interface Resource { /* shape */}
+interface Tool { /* shape */}
+interface Prompt { /* shape */}
+type PrimitiveValue = Resource | Tool | Prompt;
+
+interface Primitive {
+  type: "resource" | "tool" | "prompt";
+  value: PrimitiveValue;
+}

48-80: listPrimitives merges capability checks with asynchronous calls.

  1. The approach is valid and merges results from multiple promises.
  2. Consider an early break if no capabilities exist to optimize performance in some edge cases.
  3. See if any concurrency issues might arise if the server is large or if many resources are loaded at once.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e1ba8f1 and fe67f79.

📒 Files selected for processing (4)
  • app/mcp/actions.ts (1 hunks)
  • app/mcp/client.ts (1 hunks)
  • app/mcp/types.ts (1 hunks)
  • app/store/chat.ts (7 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/mcp/actions.ts
🔇 Additional comments (14)
app/store/chat.ts (4)

Line range hint 1-37: LGTM! Import changes are well-organized.

The new imports for MCP functionality are properly structured and necessary for the implementation.


62-62: LGTM! Type extension is clean and minimal.

The addition of isMcpResponse to ChatMessage type is well-typed and follows TypeScript best practices.


368-372: LGTM! Clean integration of MCP checking.

The addition of checkMcpJson call is well-placed and maintains the existing message processing flow.


Line range hint 1-810: Verify integration with existing chat functionality.

Since this is a WIP PR adding MCP support, please ensure:

  1. The changes don't affect existing chat functionality
  2. Error states are properly propagated to the UI
  3. MCP responses don't break the chat history display
✅ Verification successful

Based on the verification results, I can now provide a final response:

MCP integration maintains existing chat functionality with proper error handling

The code review shows that the MCP (Message Control Protocol) integration:

  1. Properly maintains existing chat functionality:

    • Core message handling (onNewMessage, onUserInput) remains intact
    • Message rendering and display components are unaffected
    • Existing error states and UI feedback are preserved
  2. Has appropriate error handling:

    • MCP errors are caught and displayed via showToast
    • Failed MCP actions are properly logged: console.error("[MCP Error]", error)
    • Error states are propagated to the UI through existing message error flags
  3. Safely integrates with chat history:

    • MCP responses are clearly marked with isMcpResponse flag
    • Messages are properly added to chat history with correct formatting
    • Template handling is properly skipped for MCP responses
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for potential regressions in chat functionality
echo "Checking for chat message handling..."
rg -A 5 "onUserInput|onNewMessage" --type ts

echo "Checking for error handling patterns..."
rg "showToast|console\.error" --type ts

echo "Checking for message display components..."
rg -A 5 "ChatMessage|renderMessage" --type tsx

Length of output: 10897


Script:

#!/bin/bash
# Let's check for message display components with proper extension
echo "Checking for message display components..."
rg -A 5 "ChatMessage|renderMessage" --type ts --type tsx

# Check for MCP-related changes
echo "Checking for MCP-related code..."
rg -A 5 "mcp|MCP" --type ts --type tsx

# Check for error handling in chat store
echo "Checking error handling in chat store..."
ast-grep --pattern 'onError(error) {
  $$$
}'

Length of output: 464


Script:

#!/bin/bash
# Let's try with just ts extension first
echo "Checking for message display components..."
rg -A 5 "ChatMessage|renderMessage" ./*.ts ./app/**/*.ts

echo "Checking for MCP-related code..."
rg -A 5 "mcp|MCP" ./*.ts ./app/**/*.ts

echo "Checking error handling in chat store..."
rg -A 5 "onError.*{" ./app/store/chat.ts

# Check for message rendering components
echo "Checking message components..."
fd -e tsx . -x cat {} | rg -A 5 "ChatMessage|renderMessage"

Length of output: 23199

app/mcp/types.ts (5)

5-12: Interfaces with typed methods and flexible params are well structured.

The McpRequestMessage interface design uses a union for the id and retains flexibility in params. This is good for requests where the schema can evolve over time.


14-20: Schema validation ensures robust request handling.

Good use of Zod for optional jsonrpc and union types for id. This schema can mitigate malformed requests by typechecking at runtime.


34-47: Robust schema for JSON-RPC responses.

The optional error object’s shape is well-defined. Ensure the client code handles partial responses (e.g., result or error fields) gracefully.


49-55: Encapsulated notifications match JSON-RPC patterns.

Separating notifications into a distinct interface clarifies the difference between requests and notifications.


57-61: Notifications schema aligns with the interface.

The use of z.record(z.unknown()) for params preserves flexibility while still enforcing structural constraints.

app/mcp/client.ts (5)

1-6: Imports are consistent and descriptive.

All necessary dependencies (Client, StdioClientTransport, custom logger, and McpRequestMessage) are imported cleanly. The use of zod is appropriate for runtime type checks.


7-11: ServerConfig is concise and extendable.

Storing command, arguments, and environment variables in an interface fosters clarity. If future expansions are likely (e.g., working directories, timeouts), consider grouping them under optional sub-objects or adding additional properties.


13-14: Logger usage is straightforward.

A dedicated logger is beneficial for debugging and operational visibility. Ensure logging levels are adjustable in production environments if needed.


15-41: createClient handles basic client setup.

  1. Logging the server name is helpful for troubleshooting.
  2. Consider error handling around client.connect in case the process fails to start or times out.

Would you like a script to search for unhandled promise rejections around connect calls and propose structured error-handling code if discovered?


82-88: 🛠️ Refactor suggestion

executeRequest returns data without intermediate validation or error handling.

Even though z.any() is used, you might want stronger type checks if the response format is critical. Also, consider how errors from client.request are caught and propagated.

 export async function executeRequest(
   client: Client,
   request: McpRequestMessage,
 ) {
-  return client.request(request, z.any());
+  try {
+    const response = await client.request(request, z.unknown());
+    // Potentially parse the response with the McpResponseMessageSchema
+    return McpResponseMessageSchema.parse(response);
+  } catch (err) {
+    logger.error('Failed to execute MCP request', err);
+    throw err;
+  }
 }

Likely invalid or redundant comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
app/mcp/actions.ts (1)

66-86: Enhance error handling with specific error types.

The error handling could be more specific to help with debugging and user feedback.

export async function executeMcpAction(
  clientId: string,
  request: McpRequestMessage,
) {
  try {
    const client = clientsMap.get(clientId)?.client;
    if (!client) {
-     logger.error(`Client ${clientId} not found`);
-     return;
+     throw new Error(`MCP client '${clientId}' not found`);
    }

    logger.info(`Executing MCP request for ${clientId}`);
    return await executeRequest(client, request);
  } catch (error) {
-   logger.error(`MCP execution error: ${error}`);
-   throw error;
+   const errorMessage = error instanceof Error ? error.message : String(error);
+   logger.error(`MCP execution error for client '${clientId}':`, errorMessage);
+   throw new Error(`Failed to execute MCP action: ${errorMessage}`);
  }
}
app/store/chat.ts (1)

813-840: Enhance error handling in MCP JSON processing.

The error handling could be more specific and provide better user feedback.

checkMcpJson(message: ChatMessage) {
  const content = getMessageTextContent(message);
  if (isMcpJson(content)) {
    try {
      const mcpRequest = extractMcpJson(content);
      if (mcpRequest) {
        console.debug("[MCP Request]", mcpRequest);

        executeMcpAction(mcpRequest.clientId, mcpRequest.mcp)
          .then((result) => {
            console.log("[MCP Response]", result);
            const mcpResponse =
              typeof result === "object"
                ? JSON.stringify(result)
                : String(result);
            get().onUserInput(
              `\`\`\`json:mcp-response:${mcpRequest.clientId}\n${mcpResponse}\n\`\`\``,
              [],
              true,
            );
          })
-         .catch((error) => showToast("MCP execution failed", error));
+         .catch((error) => {
+           const errorMessage = error instanceof Error ? error.message : String(error);
+           showToast(
+             "MCP Execution Failed",
+             `Failed to execute MCP action for client '${mcpRequest.clientId}': ${errorMessage}`
+           );
+           console.error("[MCP Execution Error]", error);
+         });
      }
    } catch (error) {
-     console.error("[MCP Error]", error);
+     const errorMessage = error instanceof Error ? error.message : String(error);
+     console.error("[MCP Processing Error]", error);
+     showToast(
+       "MCP Processing Failed",
+       `Failed to process MCP message: ${errorMessage}`
+     );
    }
  }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fe67f79 and f2a2b40.

📒 Files selected for processing (6)
  • app/components/chat.tsx (11 hunks)
  • app/constant.ts (1 hunks)
  • app/mcp/actions.ts (1 hunks)
  • app/mcp/client.ts (1 hunks)
  • app/mcp/example.ts (1 hunks)
  • app/store/chat.ts (11 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/components/chat.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/mcp/example.ts
🔇 Additional comments (7)
app/constant.ts (2)

256-261: LGTM! Well-structured template for MCP primitives.

The template clearly separates clientId and primitives sections with good formatting.


263-365: LGTM! Comprehensive system template with clear documentation.

The template provides:

  • Clear sections for tools, usage rules, and interaction flow
  • Well-documented examples
  • Proper markdown formatting for code blocks
app/mcp/client.ts (3)

43-46: 🛠️ Refactor suggestion

Replace 'any' type with a more specific type.

The value field uses the any type which reduces type safety. Consider defining a proper type or interface.

export interface Primitive {
  type: "resource" | "tool" | "prompt";
-  value: any;
+  value: {
+    name: string;
+    description?: string;
+    parameters?: Record<string, unknown>;
+  };
}

Likely invalid or redundant comment.


82-88: 🛠️ Refactor suggestion

Improve request validation.

The function uses z.any() which bypasses Zod's type validation benefits. Consider implementing proper validation schema.

export async function executeRequest(
  client: Client,
  request: McpRequestMessage,
) {
-  return client.request(request, z.any());
+  const responseSchema = z.object({
+    // Define expected response schema
+    result: z.unknown(),
+    error: z.string().optional(),
+  });
+  return client.request(request, responseSchema);
}

Likely invalid or redundant comment.


15-41: ⚠️ Potential issue

Add error handling for client connection.

The client connection lacks error handling which could lead to unhandled promise rejections.

export async function createClient(
  serverConfig: ServerConfig,
  name: string,
): Promise<Client> {
  logger.info(`Creating client for server ${name}`);

  const transport = new StdioClientTransport({
    command: serverConfig.command,
    args: serverConfig.args,
    env: serverConfig.env,
  });
  const client = new Client(
    {
      name: `nextchat-mcp-client-${name}`,
      version: "1.0.0",
    },
    {
      capabilities: {
        // roots: {
        //   listChanged: true,
        // },
      },
    },
  );
-  await client.connect(transport);
+  try {
+    await client.connect(transport);
+  } catch (error) {
+    logger.error(`Failed to connect client ${name}:`, error);
+    throw new Error(`Failed to initialize MCP client ${name}: ${error.message}`);
+  }
  return client;
}

Likely invalid or redundant comment.

app/mcp/actions.ts (1)

28-63: LGTM! Well-implemented initialization with proper error handling.

The function includes:

  • Singleton pattern to prevent multiple initializations
  • Comprehensive error handling
  • Good logging of success and failure cases
app/store/chat.ts (1)

201-219: LGTM! Well-implemented system prompt generation.

The function effectively:

  • Filters relevant primitives
  • Handles template replacement
  • Maintains clear structure

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (14)
app/constant.ts (1)

264-366: Consider enhancing the system template documentation.

The template is well-structured with comprehensive documentation. Consider these improvements:

  1. Add version information to track template changes
  2. Use more realistic paths in examples (e.g., ~/Desktop or C:\Users\username\Desktop)
 export const MCP_SYSTEM_TEMPLATE = `
+// Template Version: 1.0.0
 You are an AI assistant with access to system tools...
 
 5. EXAMPLE INTERACTION:
    User: "What files do I have on my desktop?"
    Assistant: "I'll check which directories I have access to.
    \`\`\`json:mcp:filesystem
    {
      "method": "tools/call",
      "params": {
        "name": "list_allowed_directories",
        "arguments": {}
      }
    }
    \`\`\`"

    User: "\`\`\`json:mcp-response:filesystem
    {
-     "directories": ["/path/to/desktop"]
+     "directories": ["~/Desktop"]
    }
    \`\`\`"
app/mcp/actions.ts (3)

52-68: Consolidate reinitializeMcpClients and restartAllClients Functions

The functions reinitializeMcpClients (lines 52-68) and restartAllClients (lines 179-194) perform similar actions: closing clients, clearing states, and reinitializing MCP clients. To avoid code duplication and improve maintainability, consider refactoring restartAllClients to call reinitializeMcpClients.

Apply this refactor:

 export async function restartAllClients() {
   logger.info("Restarting all MCP clients...");

-  // 清空状态
-  clientsMap.clear();
-  errorClients = [];
-  initialized = false;
-
-  // 重新初始化
-  await initializeMcpClients();
+  // Delegate to reinitializeMcpClients
+  await reinitializeMcpClients();

   return {
     success: errorClients.length === 0,
     errorClients,
   };
 }

123-127: Improve Error Handling When Client Is Not Found

In the executeMcpAction function (lines 123-127), when a client is not found, the function logs an error but does not throw an exception or provide feedback to the caller. This could lead to silent failures. Consider throwing an error to ensure that the calling function can handle this scenario appropriately.

Apply this change:

     const client = clientsMap.get(clientId)?.client;
     if (!client) {
       logger.error(`Client ${clientId} not found`);
-      return;
+      throw new Error(`Client ${clientId} not found`);
     }

197-216: Combine getAllClientStatus and getClientErrors Functions

The functions getAllClientStatus (lines 197-205) and getClientErrors (lines 208-216) both return a record of client IDs to their error messages. To reduce redundancy, consider combining these functions into one or clarifying their distinct purposes if they are intended to provide different information.

app/components/mcp-market.tsx (2)

185-250: Refactor renderConfigForm to Improve Readability

The renderConfigForm function (lines 181-250) handles multiple input types and contains nested loops and conditional logic, making it complex. Consider refactoring by extracting input field rendering into separate components to enhance readability and maintainability.


436-438: Handle Long Descriptions in Server Info

In the server info section (lines 436-438), long descriptions may overflow or break the layout. Consider adding CSS styles to handle text overflow, such as ellipsis, or provide tooltips for full descriptions.

app/components/home.tsx (1)

77-83: Maintain Consistent Import Order

The import order of useEffect and useState (line 5) deviates from the convention used in the rest of the file, where hooks are typically imported after other modules. Consider reorganizing the imports for consistency.

app/mcp/types.ts (2)

5-61: LGTM! Well-structured message types with proper validation.

The MCP message interfaces and schemas are well-defined and properly validated using Zod. The implementation follows the JSON-RPC 2.0 specification.

Consider adding:

  1. JSDoc comments for better IDE integration
  2. Examples of valid message structures
  3. Constants for common error codes

Example:

/** MCP request message following JSON-RPC 2.0 specification */
export interface McpRequestMessage {
  /** JSON-RPC version. Must be "2.0" when present */
  jsonrpc?: "2.0";
  // ... rest of the interface
}

/** Common MCP error codes */
export const McpErrorCodes = {
  PARSE_ERROR: -32700,
  INVALID_REQUEST: -32600,
  METHOD_NOT_FOUND: -32601,
  // ... add more error codes
} as const;

63-99: LGTM! Well-designed server configuration types.

The server configuration interfaces provide good type safety and flexibility for different server configurations.

Consider adding:

  1. Type guards for runtime validation
  2. Utility functions for configuration validation
  3. Constants for common server types

Example:

export const SERVER_TYPES = {
  FILESYSTEM: 'filesystem',
  DOCKER: 'docker-mcp',
  POSTGRES: 'postgres',
  // ... add more server types
} as const;

export type ServerType = typeof SERVER_TYPES[keyof typeof SERVER_TYPES];

export function isValidServerConfig(config: unknown): config is ServerConfig {
  // Add runtime validation logic
}
app/mcp/preset-server.json (2)

74-78: Enhance database connection security

Both MongoDB and PostgreSQL configurations use plain connection strings. Consider:

  • Supporting connection options (SSL, timeout, etc.)
  • Implementing credential management
  • Adding connection pooling configuration

Also applies to: 138-142


161-165: Add API configuration safeguards

For both Brave Search and Google Maps APIs, consider adding:

  • Rate limiting configuration
  • Error handling guidance
  • API key rotation support

Also applies to: 184-188

app/components/mcp-market.module.scss (3)

86-95: Extract status colors to CSS variables

Replace hardcoded colors with CSS variables for consistency:

-              background-color: #10b981;
+              background-color: var(--status-success);
-              background-color: #ef4444;
+              background-color: var(--status-error);
-              background-color: #f59e0b;
+              background-color: var(--status-warning);

188-389: Reduce style duplication with mixins

Consider extracting common input styles into SCSS mixins:

  • Form input styles
  • Button hover/focus states
  • Common transitions

574-612: Move global styles to a separate file

Global styles should be moved to a dedicated global stylesheet to:

  • Prevent scope conflicts
  • Improve maintainability
  • Better separate concerns
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2a2b40 and 7d51bfd.

⛔ Files ignored due to path filters (2)
  • app/icons/mcp.svg is excluded by !**/*.svg
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (13)
  • app/components/home.tsx (4 hunks)
  • app/components/mcp-market.module.scss (1 hunks)
  • app/components/mcp-market.tsx (1 hunks)
  • app/components/sidebar.tsx (2 hunks)
  • app/constant.ts (2 hunks)
  • app/locales/cn.ts (1 hunks)
  • app/mcp/actions.ts (1 hunks)
  • app/mcp/mcp_config.json (1 hunks)
  • app/mcp/preset-server.json (1 hunks)
  • app/mcp/types.ts (1 hunks)
  • app/mcp/utils.ts (1 hunks)
  • app/store/chat.ts (11 hunks)
  • next.config.mjs (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • next.config.mjs
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/mcp/utils.ts
  • app/store/chat.ts
🔇 Additional comments (11)
app/constant.ts (3)

50-50: LGTM! Path addition follows conventions.

The new McpMarket path is well-structured and consistent with existing path definitions.


257-262: LGTM! Clean and focused template structure.

The template follows the existing patterns and provides a clear structure for clientId and primitives interpolation.


257-367: LGTM! Well-integrated with existing constants.

The new MCP-related constants are properly placed within the file's organization, maintaining logical grouping and following existing patterns.

app/mcp/actions.ts (1)

23-66: ⚠️ Potential issue

Ensure Thread-Safe Access to Shared State Variables

The module uses shared state variables (clientsMap, initialized, errorClients) without synchronization mechanisms. If functions like initializeMcpClients or reinitializeMcpClients are called concurrently, it may lead to race conditions or inconsistent state. Consider implementing synchronization to ensure thread-safe operations.

To verify concurrency issues, please review how and where these functions are invoked. If they can be called concurrently, synchronization mechanisms like mutexes or atomic variables should be introduced to protect shared state.

app/components/mcp-market.tsx (1)

253-270: Ensure Robust Error Handling When Loading Primitives

In the loadPrimitives function (lines 253-270), if the server is not running, an empty array is set for primitives. Ensure that components consuming primitives can handle empty arrays without errors to prevent potential runtime issues.

app/components/home.tsx (1)

77-83: Verify Dynamic Import Path for McpMarketPage

Ensure that the dynamic import path './mcp-market' (lines 77-83) correctly resolves to the McpMarketPage component. This is important for the component to load properly, especially in build and deployment environments.

app/components/sidebar.tsx (1)

254-262: LGTM!

The new MCP icon button is well-integrated into the sidebar, following the existing patterns for icon buttons and conditional rendering.

app/locales/cn.ts (1)

629-631: LGTM!

The MCP localization entry follows the established pattern and maintains consistency with other localization entries.

app/mcp/preset-server.json (3)

11-16: Add path validation constraints for filesystem access

The filesystem paths configuration lacks validation constraints. Consider adding:

  • Path pattern restrictions
  • Absolute/relative path validation
  • Directory traversal prevention

35-39: Specify required GitHub token scopes

The GitHub PAT configuration should specify the minimum required scopes for security. Consider adding:

  • List of required scopes in the description
  • Scope validation in the implementation

199-204: Enhance Docker configuration security

The Docker module lacks essential configuration options. Consider adding:

  • Container resource limits
  • Security options (e.g., no-new-privileges)
  • Network access controls

Comment on lines 35 to 38
} catch (error) {
console.error("Failed to read MCP config:", error);
return { mcpServers: {} };
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Handle Missing Configuration File Gracefully

In the getMcpConfig function (lines 35-38), if the configuration file is missing (e.g., on the first run), it logs an error. Instead, consider checking if the error is due to the file not existing (ENOENT) and initialize with a default configuration without logging an error. This provides a smoother user experience.

Apply this change:

     } catch (error) {
-      console.error("Failed to read MCP config:", error);
-      return { mcpServers: {} };
+      if (error.code === 'ENOENT') {
+        logger.warn("MCP config file not found, initializing with default configuration.");
+        return { mcpServers: {} };
+      } else {
+        logger.error("Failed to read MCP config:", error);
+        throw error;
+      }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} catch (error) {
console.error("Failed to read MCP config:", error);
return { mcpServers: {} };
}
} catch (error) {
if (error.code === 'ENOENT') {
logger.warn("MCP config file not found, initializing with default configuration.");
return { mcpServers: {} };
} else {
logger.error("Failed to read MCP config:", error);
throw error;
}
}

Comment on lines 130 to 135

try {
// 构建服务器配置
const args = [...preset.baseArgs];
const env: Record<string, string> = {};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add Null Checks for preset.configSchema Before Use

In the saveServerConfig function (lines 130-135), preset.configSchema is accessed without null checks. If preset.configSchema is undefined or null, it may cause runtime errors. Ensure that preset.configSchema is validated before accessing its properties.

Apply this change:

     if (!preset || !preset.configSchema || !editingServerId) return;

+    if (!preset.configSchema) {
+      showToast("Server configuration schema is missing.");
+      return;
+    }

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines 393 to 404
const bError = clientErrors[b.id] !== null;

if (aAdded !== bAdded) {
return aAdded ? -1 : 1;
}
if (aAdded && bAdded) {
if (aError !== bError) {
return aError ? -1 : 1;
}
}
return 0;
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Correct Sorting Logic for Server Error Status

In the server list sorting logic (lines 389-404), the comparison of aError and bError may be inverted, causing servers with errors to appear before those without. Adjust the sorting condition to ensure servers without errors are prioritized.

Apply this fix:

           if (aAdded && bAdded) {
             if (aError !== bError) {
-              return aError ? -1 : 1;
+              return aError ? 1 : -1;
             }
           }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const bError = clientErrors[b.id] !== null;
if (aAdded !== bAdded) {
return aAdded ? -1 : 1;
}
if (aAdded && bAdded) {
if (aError !== bError) {
return aError ? -1 : 1;
}
}
return 0;
})
const bError = clientErrors[b.id] !== null;
if (aAdded !== bAdded) {
return aAdded ? -1 : 1;
}
if (aAdded && bAdded) {
if (aError !== bError) {
return aError ? 1 : -1;
}
}
return 0;
})

Comment on lines 1 to 36
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/kadxy/Desktop"
]
},
"docker-mcp": {
"command": "uvx",
"args": ["docker-mcp"]
},
"difyworkflow": {
"command": "mcp-difyworkflow-server",
"args": ["-base-url", "23"],
"env": {
"DIFY_WORKFLOW_NAME": "23",
"DIFY_API_KEYS": "23"
}
},
"postgres": {
"command": "docker",
"args": ["run", "-i", "--rm", "mcp/postgres", null]
},
"playwright": {
"command": "npx",
"args": ["-y", "@executeautomation/playwright-mcp-server"]
},
"gdrive": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-gdrive"]
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add documentation and validation guidance.

The configuration file lacks documentation for server configurations and validation requirements.

Consider adding:

  1. A documentation section describing each server type and its purpose
  2. Required environment variables for each server
  3. Validation rules for configuration parameters
  4. Error handling guidance

Example structure:

{
  "documentation": {
    "version": "1.0",
    "servers": {
      "filesystem": {
        "description": "Local filesystem MCP server",
        "required_env": ["MCP_FILESYSTEM_PATH"],
        "validation": {
          "MCP_FILESYSTEM_PATH": "Must be a valid directory path"
        }
      },
      // ... other servers
    }
  },
  "mcpServers": {
    // ... existing configurations
  }
}

Comment on lines 23 to 26
"postgres": {
"command": "docker",
"args": ["run", "-i", "--rm", "mcp/postgres", null]
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix null argument in postgres configuration.

The postgres server configuration contains a null argument which could cause runtime issues.

Remove the null argument or replace it with a valid value:

-      "args": ["run", "-i", "--rm", "mcp/postgres", null]
+      "args": ["run", "-i", "--rm", "mcp/postgres"]
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"postgres": {
"command": "docker",
"args": ["run", "-i", "--rm", "mcp/postgres", null]
},
"postgres": {
"command": "docker",
"args": ["run", "-i", "--rm", "mcp/postgres"]
},

Comment on lines 15 to 22
"difyworkflow": {
"command": "mcp-difyworkflow-server",
"args": ["-base-url", "23"],
"env": {
"DIFY_WORKFLOW_NAME": "23",
"DIFY_API_KEYS": "23"
}
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Replace placeholder values in difyworkflow configuration.

The configuration contains placeholder values "23" for base URL and API keys, which are not valid production values.

Consider using environment variables:

-      "args": ["-base-url", "23"],
+      "args": ["-base-url", "${DIFY_BASE_URL}"],
       "env": {
-        "DIFY_WORKFLOW_NAME": "23",
-        "DIFY_API_KEYS": "23"
+        "DIFY_WORKFLOW_NAME": "${DIFY_WORKFLOW_NAME}",
+        "DIFY_API_KEYS": "${DIFY_API_KEYS}"
       }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"difyworkflow": {
"command": "mcp-difyworkflow-server",
"args": ["-base-url", "23"],
"env": {
"DIFY_WORKFLOW_NAME": "23",
"DIFY_API_KEYS": "23"
}
},
"difyworkflow": {
"command": "mcp-difyworkflow-server",
"args": ["-base-url", "${DIFY_BASE_URL}"],
"env": {
"DIFY_WORKFLOW_NAME": "${DIFY_WORKFLOW_NAME}",
"DIFY_API_KEYS": "${DIFY_API_KEYS}"
}
},

Comment on lines 3 to 10
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/kadxy/Desktop"
]
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Remove hardcoded filesystem path.

The filesystem server configuration contains a hardcoded path /Users/kadxy/Desktop which will not work across different environments and could pose security risks.

Consider using environment variables or configuration parameters for the path:

-        "/Users/kadxy/Desktop"
+        "${MCP_FILESYSTEM_PATH}"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/kadxy/Desktop"
]
},
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"${MCP_FILESYSTEM_PATH}"
]
},

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
app/components/mcp-market.tsx (1)

640-646: 🛠️ Refactor suggestion

Add accessibility improvements to the search input.

The search input lacks proper accessibility attributes.

 <input
   type="text"
   className={styles["search-bar"]}
   placeholder={"Search MCP Server"}
   autoFocus
   onInput={(e) => setSearchText(e.currentTarget.value)}
+  aria-label="Search MCP servers"
+  role="searchbox"
+  aria-describedby="search-description"
 />
+<span id="search-description" className="sr-only">
+  Search for MCP servers by name, description, or tags
+</span>
🧹 Nitpick comments (3)
app/components/mcp-market.tsx (3)

34-40: Enhance type safety of ConfigProperty interface.

Consider improving type safety by:

  1. Making the type field more specific using a union type of allowed values
  2. Adding validation for minItems to ensure it's positive
 interface ConfigProperty {
-  type: string;
+  type: 'string' | 'array' | 'number' | 'boolean';
   description?: string;
   required?: boolean;
-  minItems?: number;
+  minItems?: number & { [K in number]: K extends number ? (K extends Positive ? K : never) : never };
 }

43-54: Consider consolidating related state using useReducer.

The component uses multiple useState hooks for related state management. Consider using useReducer to consolidate server-related states (config, status, tools) into a single reducer for better maintainability and state updates consistency.

interface ServerState {
  config: McpConfigData | undefined;
  clientStatuses: Record<string, ServerStatusResponse>;
  tools: ListToolsResponse["tools"] | null;
  isLoading: boolean;
}

type ServerAction = 
  | { type: 'SET_CONFIG'; payload: McpConfigData }
  | { type: 'UPDATE_STATUS'; payload: { id: string; status: ServerStatusResponse } }
  | { type: 'SET_TOOLS'; payload: ListToolsResponse["tools"] | null }
  | { type: 'SET_LOADING'; payload: boolean };

285-304: Improve error handling in pauseServer function.

The error handling could be more specific and informative. Consider:

  1. Adding error type checking
  2. Providing more detailed error messages
  3. Implementing retry logic for transient failures
   try {
     setIsLoading(true);
     showToast("Stopping server...");
     const newConfig = await pauseMcpServer(id);
     setConfig(newConfig);

     setClientStatuses((prev) => ({
       ...prev,
       [id]: { status: "paused", errorMsg: null },
     }));
     showToast("Server stopped successfully");
   } catch (error) {
-    showToast("Failed to stop server");
-    console.error(error);
+    const errorMessage = error instanceof Error 
+      ? `Failed to stop server: ${error.message}`
+      : "Failed to stop server: Unknown error";
+    logger.error(errorMessage, { serverId: id, error });
+    showToast(errorMessage);
   } finally {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d63d73 and 588d81e.

📒 Files selected for processing (1)
  • app/components/mcp-market.tsx (1 hunks)
🔇 Additional comments (2)
app/components/mcp-market.tsx (2)

364-373: 🛠️ Refactor suggestion

Add input validation and accessibility improvements.

The input field lacks validation and proper accessibility attributes.

 <input
   type="text"
   value={value}
+  aria-label={`${itemLabel} ${index + 1}`}
+  aria-required={prop.required}
   placeholder={`${itemLabel} ${index + 1}`}
   onChange={(e) => {
+    const sanitizedValue = e.target.value.trim();
+    if (prop.pattern && !new RegExp(prop.pattern).test(sanitizedValue)) {
+      showToast(`Invalid ${itemLabel} format`);
+      return;
+    }
     const newValue = [...currentValue] as string[];
-    newValue[index] = e.target.value;
+    newValue[index] = sanitizedValue;
     setUserConfig({ ...userConfig, [key]: newValue });
   }}
 />

Likely invalid or redundant comment.


66-69: 🛠️ Refactor suggestion

Replace console.error with proper error logging.

Console statements should not be used in production code. Consider implementing a proper logging service.

-      console.error("Failed to load preset servers:", error);
+      logger.error("Failed to load preset servers:", error);
       showToast("Failed to load preset servers");

Likely invalid or redundant comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
app/constant.ts (2)

258-263: Consider improving template readability.

The template structure is functional but could be more maintainable.

Consider using this more structured format:

-export const MCP_TOOLS_TEMPLATE = `
-[clientId]
-{{ clientId }}
-[tools]
-{{ tools }}
-`;
+export const MCP_TOOLS_TEMPLATE = `
+# Client Information
+Client ID: {{ clientId }}
+
+# Available Tools
+{{ tools }}
+`;

265-380: Review and enhance the MCP system template.

The template has several areas that could be improved:

  1. The example interaction shows Chinese text which may not be universally understood
  2. There are multiple exclamation marks used for emphasis which could be replaced with more professional formatting
  3. The error examples could be better structured

Consider these improvements:

 4. INTERACTION FLOW:
    A. When user makes a request:
       - IMMEDIATELY use appropriate tool if available
       - DO NOT ask if user wants you to use the tool
       - DO NOT just describe what you could do
    B. After receiving tool response:
       - Explain results clearly
       - Take next appropriate action if needed
    C. If tools fail:
       - Explain the error
       - Try alternative approach immediately

 5. EXAMPLE INTERACTION:
-  good example:
+  # Correct Example:
+  # List allowed directories
 
    ```json:mcp:filesystem
    {
      "method": "tools/call",
      "params": {
        "name": "list_allowed_directories",
        "arguments": {}
      }
    }
    ```

+  # Write a file
    ```json:mcp-response:filesystem
    {
      "method": "tools/call",
      "params": {
        "name": "write_file",
        "arguments": {
-         "path": "/Users/river/dev/nextchat/test/joke.txt",
-         "content": "为什么数学书总是感到忧伤?因为它有太多的问题。"
+         "path": "/Users/example/docs/greeting.txt",
+         "content": "Hello, World!"
        }
      }
    }
    ```

-   follwing is the wrong! mcp json example:
+   # Common Mistakes:
+   # 1. Incorrect method name
 
    ```json:mcp:filesystem
    {
       "method": "write_file",  # Wrong: should be "tools/call"
       "params": {
         "path": "NextChat_Information.txt",
         "content": "1"
     }
    }
    ```
-   This is wrong because the method is not tools/call.
   
+   # 2. Missing mcp prefix in code block
    ```{
     "method": "search_repositories",
     "params": {
       "query": "2oeee"
     }
   }
    ```
-   This is wrong because the method is not tools/call.!!!!!!!!!!!
+   # Correct Format Reference:
 
-   the right format is:
    ```json:mcp:filesystem
    {
      "method": "tools/call",
      "params": {
        "name": "search_repositories",
        "arguments": {
          "query": "2oeee"
        }
      }
    }
    ```
   
-   please follow the format strictly ONLY use tools/call method!!!!!!!!!!!
+   Note: Always use the "tools/call" method and follow the format strictly.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 588d81e and 4d535b1.

📒 Files selected for processing (1)
  • app/constant.ts (3 hunks)
🔇 Additional comments (3)
app/constant.ts (3)

50-50: LGTM! Path enum updated correctly.

The new McpMarket path follows the existing naming convention and is properly formatted.


91-91: LGTM! StoreKey enum updated correctly.

The new Mcp key follows the existing naming convention and is properly formatted.


258-380: Verify the usage of MCP constants across the codebase.

Let's ensure these new constants are properly imported and used in other files.

✅ Verification successful

Constants are properly used across the codebase

The MCP constants are correctly imported and used in app/store/chat.ts with proper template substitution. No issues found with hardcoded values or inconsistent usage.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check for imports of the new MCP constants
echo "Checking imports of MCP constants..."
rg -l "MCP_TOOLS_TEMPLATE|MCP_SYSTEM_TEMPLATE" --type ts --type tsx

# Check for potential usages of hardcoded strings that should use these constants
echo "Checking for hardcoded MCP strings that should use constants..."
rg -l "tools/call" --type ts --type tsx

Length of output: 385


Script:

#!/bin/bash
# Find all TypeScript files including React ones
echo "TypeScript files containing MCP constants:"
fd -e ts -e tsx | xargs rg -l "MCP_TOOLS_TEMPLATE|MCP_SYSTEM_TEMPLATE"

echo -e "\nFiles with potential hardcoded 'tools/call' usage:"
fd -e ts -e tsx | xargs rg -l "tools/call"

# Get context around tools/call usage to verify if they should use the constants
echo -e "\nContext of tools/call usage:"
fd -e ts -e tsx | xargs rg -C 3 "tools/call"

Length of output: 3039


Script:

#!/bin/bash
# Check how the constants are used in chat.ts
echo "Usage of MCP constants in chat.ts:"
rg -C 5 "MCP_.*_TEMPLATE" app/store/chat.ts

Length of output: 872

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 7

🧹 Nitpick comments (7)
app/mcp/actions.ts (2)

26-60: Consider refactoring status checks for better maintainability.

The function has multiple return points and nested conditions. Consider using a single status object that's modified based on conditions, then returned at the end.

 export async function getClientStatus(
   clientId: string,
 ): Promise<ServerStatusResponse> {
+  let status: ServerStatusResponse = { status: "undefined", errorMsg: null };
   const clientData = clientsMap.get(clientId);
   const config = await getMcpConfigFromFile();
   const serverConfig = config.mcpServers[clientId];

-  if (!serverConfig) {
-    return { status: "undefined", errorMsg: null };
+  if (serverConfig) {
+    if (serverConfig.status === "paused") {
+      status = { status: "paused", errorMsg: null };
+    } else if (clientData) {
+      if (clientData.errorMsg) {
+        status = { status: "error", errorMsg: clientData.errorMsg };
+      } else if (clientData.client) {
+        status = { status: "active", errorMsg: null };
+      } else {
+        status = { status: "error", errorMsg: "Client not found" };
+      }
+    }
   }

-  if (serverConfig.status === "paused") {
-    return { status: "paused", errorMsg: null };
-  }
-
-  if (!status) {
-    return { status: "undefined", errorMsg: null };
-  }
-
-  if (status.errorMsg) {
-    return { status: "error", errorMsg: status.errorMsg };
-  }
-
-  if (status.client) {
-    return { status: "active", errorMsg: null };
-  }
-
-  return { status: "error", errorMsg: "Client not found" };
+  return status;
 }

68-72: Optimize client count calculation.

The count can be calculated more efficiently using Array methods.

 export async function getAvailableClientsCount() {
-  let count = 0;
-  clientsMap.forEach((map) => !map.errorMsg && count++);
-  return count;
+  return Array.from(clientsMap.values()).filter(map => !map.errorMsg).length;
 }
app/components/mcp-market.module.scss (4)

8-14: Add ARIA attributes to loading indicator.

Enhance accessibility for screen readers.

 .loading-indicator {
   font-size: 12px;
   color: var(--primary);
   margin-left: 8px;
   font-weight: normal;
   opacity: 0.8;
+  &[aria-busy="true"] {
+    cursor: progress;
+  }
 }

30-30: Define animation duration as a variable.

Extract the animation duration to a variable for better maintainability.

+$animation-duration: 0.3s;
+
 animation: slide-in ease 0.3s;

115-116: Use CSS variables for consistent colors.

Replace hardcoded color values with CSS variables for better maintainability.

-  background-color: #16a34a;
+  background-color: var(--success-color);

-  background-color: #22c55e;
+  background-color: var(--active-color);

-  background-color: #ef4444;
+  background-color: var(--error-color);

-  background-color: #6b7280;
+  background-color: var(--disabled-color);

Also applies to: 159-160, 163-164, 167-168


88-106: Optimize loading animation performance.

Use transform instead of opacity for better performance, and consider using will-change for hardware acceleration.

 &.loading {
   position: relative;
   &::after {
     content: "";
     position: absolute;
     top: 0;
     left: 0;
     right: 0;
     bottom: 0;
+    will-change: transform;
     background: linear-gradient(
       90deg,
       transparent,
       rgba(255, 255, 255, 0.2),
       transparent
     );
     background-size: 200% 100%;
-    animation: loading-pulse 1.5s infinite;
+    animation: loading-pulse 1.5s infinite linear;
   }
 }
app/components/mcp-market.tsx (1)

43-57: Consider using useReducer for complex state management.

The component has multiple related state variables that could be managed more effectively with useReducer.

interface McpMarketState {
  searchText: string;
  userConfig: Record<string, string | string[]>;
  editingServerId?: string;
  tools: ListToolsResponse["tools"] | null;
  viewingServerId?: string;
  isLoading: boolean;
  config?: McpConfigData;
  clientStatuses: Record<string, ServerStatusResponse>;
  loadingPresets: boolean;
  presetServers: PresetServer[];
  loadingStates: Record<string, string>;
}

type McpMarketAction =
  | { type: 'SET_SEARCH_TEXT'; payload: string }
  | { type: 'SET_USER_CONFIG'; payload: Record<string, string | string[]> }
  | { type: 'SET_EDITING_SERVER'; payload?: string }
  // ... other action types
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4d535b1 and 65810d9.

📒 Files selected for processing (3)
  • app/components/mcp-market.module.scss (1 hunks)
  • app/components/mcp-market.tsx (1 hunks)
  • app/mcp/actions.ts (1 hunks)
🔇 Additional comments (6)
app/mcp/actions.ts (4)

259-281: Fix potential memory leak in removeMcpServer.

The client's resources should be cleaned up before updating the configuration to prevent potential memory leaks.


284-306: Enhance error resilience in client restart process.

Individual client failures during restart shouldn't prevent other clients from restarting.


337-344: Implement atomic file writes for configuration updates.

Use temporary files and atomic rename operations to prevent corruption during writes.


117-124: Protect against concurrent initialization race conditions.

Multiple clients initializing simultaneously could lead to race conditions. Consider adding a lock mechanism or using a queue for initialization.

Consider implementing a queue system for client initialization:

const initQueue = new PQueue({concurrency: 1});
await initQueue.add(() => initializeSingleClient(clientId, serverConfig));
app/components/mcp-market.tsx (2)

143-215: Enhance error handling in saveServerConfig.

The function should validate configuration values before saving.


682-688: Add accessibility improvements to the search input.

The search input lacks proper accessibility attributes.

Comment on lines +327 to +335
export async function getMcpConfigFromFile(): Promise<McpConfigData> {
try {
const configStr = await fs.readFile(CONFIG_PATH, "utf-8");
return JSON.parse(configStr);
} catch (error) {
logger.error(`Failed to load MCP config, using default config: ${error}`);
return DEFAULT_MCP_CONFIG;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add configuration schema validation.

The configuration loading process should validate the structure of the loaded data against a schema to ensure integrity.

interface McpConfigSchema {
  mcpServers: Record<string, ServerConfig>;
}

function validateConfig(config: unknown): config is McpConfigData {
  const schema = z.object({
    mcpServers: z.record(z.custom<ServerConfig>())
  });
  return schema.safeParse(config).success;
}

Comment on lines 347 to 354
export async function reinitializeClient(clientId: string) {
const config = await getMcpConfigFromFile();
const serverConfig = config.mcpServers[clientId];
if (!serverConfig) {
throw new Error(`Server config not found for client ${clientId}`);
}
await initializeSingleClient(clientId, serverConfig);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance error handling in reinitializeClient.

The function should handle initialization failures gracefully and provide detailed error information.

 export async function reinitializeClient(clientId: string) {
+  logger.info(`Attempting to reinitialize client [${clientId}]...`);
   const config = await getMcpConfigFromFile();
   const serverConfig = config.mcpServers[clientId];
   if (!serverConfig) {
-    throw new Error(`Server config not found for client ${clientId}`);
+    const error = `Server config not found for client ${clientId}`;
+    logger.error(error);
+    throw new Error(error);
+  }
+  try {
     await initializeSingleClient(clientId, serverConfig);
+    logger.success(`Successfully reinitialized client [${clientId}]`);
+  } catch (error) {
+    const message = `Failed to reinitialize client [${clientId}]: ${error}`;
+    logger.error(message);
+    throw new Error(message);
   }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export async function reinitializeClient(clientId: string) {
const config = await getMcpConfigFromFile();
const serverConfig = config.mcpServers[clientId];
if (!serverConfig) {
throw new Error(`Server config not found for client ${clientId}`);
}
await initializeSingleClient(clientId, serverConfig);
}
export async function reinitializeClient(clientId: string) {
logger.info(`Attempting to reinitialize client [${clientId}]...`);
const config = await getMcpConfigFromFile();
const serverConfig = config.mcpServers[clientId];
if (!serverConfig) {
const error = `Server config not found for client ${clientId}`;
logger.error(error);
throw new Error(error);
}
try {
await initializeSingleClient(clientId, serverConfig);
logger.success(`Successfully reinitialized client [${clientId}]`);
} catch (error) {
const message = `Failed to reinitialize client [${clientId}]: ${error}`;
logger.error(message);
throw new Error(message);
}
}

Comment on lines +264 to +269
&:focus {
background-color: var(--white);
border-color: var(--primary);
outline: none;
box-shadow: 0 0 0 2px var(--primary-10);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance focus visibility for accessibility.

Improve focus state visibility for keyboard navigation.

 &:focus {
   background-color: var(--white);
   border-color: var(--primary);
   outline: none;
-  box-shadow: 0 0 0 2px var(--primary-10);
+  box-shadow: 0 0 0 3px var(--primary-20);
+  outline: 2px solid transparent;
+  outline-offset: 2px;
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
&:focus {
background-color: var(--white);
border-color: var(--primary);
outline: none;
box-shadow: 0 0 0 2px var(--primary-10);
}
&:focus {
background-color: var(--white);
border-color: var(--primary);
outline: none;
box-shadow: 0 0 0 3px var(--primary-20);
outline: 2px solid transparent;
outline-offset: 2px;
}

export function McpMarketPage() {
const navigate = useNavigate();
const [searchText, setSearchText] = useState("");
const [userConfig, setUserConfig] = useState<Record<string, any>>({});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Replace 'any' type with a proper type definition.

Using 'any' type reduces type safety and could lead to runtime errors.

-  const [userConfig, setUserConfig] = useState<Record<string, any>>({});
+  const [userConfig, setUserConfig] = useState<Record<string, string | string[]>>({});
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const [userConfig, setUserConfig] = useState<Record<string, any>>({});
const [userConfig, setUserConfig] = useState<Record<string, string | string[]>>({});

Comment on lines 59 to 77
useEffect(() => {
const loadPresetServers = async () => {
try {
setLoadingPresets(true);
const response = await fetch("https://nextchat.club/mcp/list");
if (!response.ok) {
throw new Error("Failed to load preset servers");
}
const data = await response.json();
setPresetServers(data?.data ?? []);
} catch (error) {
console.error("Failed to load preset servers:", error);
showToast("Failed to load preset servers");
} finally {
setLoadingPresets(false);
}
};
loadPresetServers().then();
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve error handling in loadPresetServers.

Add proper error handling and remove console.error calls.

 const loadPresetServers = async () => {
   try {
     setLoadingPresets(true);
     const response = await fetch("https://nextchat.club/mcp/list");
     if (!response.ok) {
-      throw new Error("Failed to load preset servers");
+      throw new Error(`Failed to load preset servers: ${response.statusText}`);
     }
     const data = await response.json();
+    if (!data?.data) {
+      throw new Error("Invalid server response format");
+    }
     setPresetServers(data?.data ?? []);
   } catch (error) {
-    console.error("Failed to load preset servers:", error);
+    logger.error("Failed to load preset servers:", error);
     showToast("Failed to load preset servers");
   } finally {
     setLoadingPresets(false);
   }
 };

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +217 to +231
// 获取服务器支持的 Tools
const loadTools = async (id: string) => {
try {
const result = await getClientTools(id);
if (result) {
setTools(result);
} else {
throw new Error("Failed to load tools");
}
} catch (error) {
showToast("Failed to load tools");
console.error(error);
setTools(null);
}
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve error handling in loadTools.

Replace console.error with proper logging and add more specific error messages.

 const loadTools = async (id: string) => {
   try {
     const result = await getClientTools(id);
     if (result) {
       setTools(result);
     } else {
-      throw new Error("Failed to load tools");
+      throw new Error(`Failed to load tools for server ${id}: No tools returned`);
     }
   } catch (error) {
-    showToast("Failed to load tools");
-    console.error(error);
+    const message = error instanceof Error ? error.message : "Unknown error";
+    logger.error(`Failed to load tools for server ${id}:`, message);
+    showToast(`Failed to load tools: ${message}`);
     setTools(null);
   }
 };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// 获取服务器支持的 Tools
const loadTools = async (id: string) => {
try {
const result = await getClientTools(id);
if (result) {
setTools(result);
} else {
throw new Error("Failed to load tools");
}
} catch (error) {
showToast("Failed to load tools");
console.error(error);
setTools(null);
}
};
// 获取服务器支持的 Tools
const loadTools = async (id: string) => {
try {
const result = await getClientTools(id);
if (result) {
setTools(result);
} else {
throw new Error(`Failed to load tools for server ${id}: No tools returned`);
}
} catch (error) {
const message = error instanceof Error ? error.message : "Unknown error";
logger.error(`Failed to load tools for server ${id}:`, message);
showToast(`Failed to load tools: ${message}`);
setTools(null);
}
};

Comment on lines +697 to +720
<Modal
title={`Configure Server - ${editingServerId}`}
onClose={() => !isLoading && setEditingServerId(undefined)}
actions={[
<IconButton
key="cancel"
text="Cancel"
onClick={() => setEditingServerId(undefined)}
bordered
disabled={isLoading}
/>,
<IconButton
key="confirm"
text="Save"
type="primary"
onClick={saveServerConfig}
bordered
disabled={isLoading}
/>,
]}
>
<List>{renderConfigForm()}</List>
</Modal>
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance modal accessibility.

Add proper ARIA attributes and keyboard navigation support to the modal.

 <Modal
   title={`Configure Server - ${editingServerId}`}
   onClose={() => !isLoading && setEditingServerId(undefined)}
+  role="dialog"
+  aria-modal="true"
+  aria-labelledby="modal-title"
   actions={[
     <IconButton
       key="cancel"
       text="Cancel"
       onClick={() => setEditingServerId(undefined)}
       bordered
       disabled={isLoading}
+      aria-label="Cancel configuration"
     />,
     <IconButton
       key="confirm"
       text="Save"
       type="primary"
       onClick={saveServerConfig}
       bordered
       disabled={isLoading}
+      aria-label="Save configuration"
     />,
   ]}
 >
+  <h2 id="modal-title" className="sr-only">
+    Configure Server - {editingServerId}
+  </h2>
   <List>{renderConfigForm()}</List>
 </Modal>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<Modal
title={`Configure Server - ${editingServerId}`}
onClose={() => !isLoading && setEditingServerId(undefined)}
actions={[
<IconButton
key="cancel"
text="Cancel"
onClick={() => setEditingServerId(undefined)}
bordered
disabled={isLoading}
/>,
<IconButton
key="confirm"
text="Save"
type="primary"
onClick={saveServerConfig}
bordered
disabled={isLoading}
/>,
]}
>
<List>{renderConfigForm()}</List>
</Modal>
</div>
<Modal
title={`Configure Server - ${editingServerId}`}
onClose={() => !isLoading && setEditingServerId(undefined)}
role="dialog"
aria-modal="true"
aria-labelledby="modal-title"
actions={[
<IconButton
key="cancel"
text="Cancel"
onClick={() => setEditingServerId(undefined)}
bordered
disabled={isLoading}
aria-label="Cancel configuration"
/>,
<IconButton
key="confirm"
text="Save"
type="primary"
onClick={saveServerConfig}
bordered
disabled={isLoading}
aria-label="Save configuration"
/>,
]}
>
<h2 id="modal-title" className="sr-only">
Configure Server - {editingServerId}
</h2>
<List>{renderConfigForm()}</List>
</Modal>
</div>

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

♻️ Duplicate comments (4)
app/components/mcp-market.tsx (4)

47-47: 🛠️ Refactor suggestion

Replace 'any' type with a proper type definition.

Using 'any' type reduces type safety and could lead to runtime errors.

Apply this diff:

-const [userConfig, setUserConfig] = useState<Record<string, any>>({});
+const [userConfig, setUserConfig] = useState<Record<string, string | string[]>>({});

238-252: 🛠️ Refactor suggestion

Improve error handling in loadTools.

Replace console.error with proper error messages.

Apply this diff:

 const loadTools = async (id: string) => {
   try {
     const result = await getClientTools(id);
     if (result) {
       setTools(result);
     } else {
-      throw new Error("Failed to load tools");
+      throw new Error(`Failed to load tools for server ${id}: No tools returned`);
     }
   } catch (error) {
-    showToast("Failed to load tools");
-    console.error(error);
+    const message = error instanceof Error ? error.message : "Unknown error";
+    showToast(`Failed to load tools: ${message}`);
     setTools(null);
   }
 };

701-707: 🛠️ Refactor suggestion

Add accessibility improvements to the search input.

The search input lacks proper accessibility attributes.

Apply this diff:

 <input
   type="text"
   className={styles["search-bar"]}
   placeholder={"Search MCP Server"}
   autoFocus
   onInput={(e) => setSearchText(e.currentTarget.value)}
+  aria-label="Search MCP servers"
+  role="searchbox"
+  aria-describedby="search-description"
 />
+<span id="search-description" className="sr-only">
+  Search for MCP servers by name, description, or tags
+</span>

716-739: 🛠️ Refactor suggestion

Enhance modal accessibility.

Add proper ARIA attributes and keyboard navigation support to the modal.

Apply this diff:

 <Modal
   title={`Configure Server - ${editingServerId}`}
   onClose={() => !isLoading && setEditingServerId(undefined)}
+  role="dialog"
+  aria-modal="true"
+  aria-labelledby="modal-title"
   actions={[
     <IconButton
       key="cancel"
       text="Cancel"
       onClick={() => setEditingServerId(undefined)}
       bordered
       disabled={isLoading}
+      aria-label="Cancel configuration"
     />,
     <IconButton
       key="confirm"
       text="Save"
       type="primary"
       onClick={saveServerConfig}
       bordered
       disabled={isLoading}
+      aria-label="Save configuration"
     />,
   ]}
 >
+  <h2 id="modal-title" className="sr-only">
+    Configure Server - {editingServerId}
+  </h2>
   <List>{renderConfigForm()}</List>
 </Modal>
🧹 Nitpick comments (8)
app/locales/en.ts (1)

638-640: LGTM on structure, consider expanding the MCP label for clarity.

The addition follows the file's structure and naming conventions correctly. However, since MCP (Multi-Channel Protocol) is a technical term, consider making it more user-friendly.

Consider this alternative to improve clarity:

  Mcp: {
-   Name: "MCP",
+   Name: "Multi-Channel Protocol (MCP)",
  },
app/mcp/actions.ts (4)

71-71: Improve readability of client counting logic

The use of logical AND (&&) for incrementing count within getAvailableClientsCount may reduce code clarity.

Consider refactoring the code for better readability:

- clientsMap.forEach((map) => !map.errorMsg && count++);
+ clientsMap.forEach((map) => {
+   if (!map.errorMsg) {
+     count++;
+   }
+ });

217-259: Handle client initialization failures without affecting configuration

In resumeMcpServer, when client initialization fails, the server configuration is updated to "error" status, which may not be ideal as it persists an error state in the configuration file.

Instead of modifying the server configuration on initialization failure, consider handling the error within the clients map only. This keeps the configuration file consistent and avoids unintended side effects:

          // 初始化失败
          clientsMap.set(clientId, {
            client: null,
            tools: null,
            errorMsg: error instanceof Error ? error.message : String(error),
          });
          logger.error(`Failed to initialize client [${clientId}]: ${error}`);
-         return false;
+         // Do not modify the configuration file
+         return await getClientStatus(clientId).then(
+           (status) => status.status === "active"
+         );

64-66: Ensure consistent null checks in getClientTools

The function getClientTools returns null if the client is not found or if tools are not available.

For better consistency, consider explicitly checking if the client exists before accessing its tools:

export async function getClientTools(clientId: string) {
-   return clientsMap.get(clientId)?.tools ?? null;
+   const clientData = clientsMap.get(clientId);
+   if (clientData && clientData.tools) {
+     return clientData.tools;
+   }
+   return null;
}

364-371: Avoid redundant error logging in isMcpEnabled

In isMcpEnabled, logging the error may be unnecessary if the function simply returns false.

Consider removing the error logging to reduce noise:

export async function isMcpEnabled() {
  try {
    const serverConfig = getServerSideConfig();
    return !!serverConfig.enableMcp;
  } catch (error) {
-   logger.error(`Failed to check MCP status: ${error}`);
    return false;
  }
}
app/layout.tsx (1)

9-9: Optimize import placement for better readability

The import of getServerSideConfig could be moved closer to its usage within RootLayout for code clarity.

If getServerSideConfig is only used inside RootLayout, consider moving the import statement inside the function scope.

app/config/server.ts (2)

85-85: Document the new environment variable ENABLE_MCP

The addition of ENABLE_MCP lacks documentation, which could cause confusion for other developers.

Add a comment explaining the purpose and expected values of ENABLE_MCP:

ENABLE_MCP?: string; // Set to 'true' to enable MCP functionality

256-256: Consistent casting of environment variables to boolean

In the configuration object, enableMcp uses !! to cast the environment variable to a boolean. Ensure this is consistent across all boolean configurations.

Review other boolean configurations to ensure consistent usage:

return {
  ...
  enableMcp: !!process.env.ENABLE_MCP,
  // For consistency, cast other booleans similarly
  hideUserApiKey: !!process.env.HIDE_USER_API_KEY,
  disableGPT4: !!process.env.DISABLE_GPT4,
  hideBalanceQuery: !!process.env.ENABLE_BALANCE_QUERY,
  disableFastLink: !!process.env.DISABLE_FAST_LINK,
  ...
};
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 65810d9 and bc71ae2.

📒 Files selected for processing (11)
  • .env.template (1 hunks)
  • Dockerfile (1 hunks)
  • app/components/chat.tsx (15 hunks)
  • app/components/home.tsx (6 hunks)
  • app/components/mcp-market.tsx (1 hunks)
  • app/components/sidebar.tsx (6 hunks)
  • app/config/server.ts (3 hunks)
  • app/layout.tsx (2 hunks)
  • app/locales/en.ts (1 hunks)
  • app/mcp/actions.ts (1 hunks)
  • app/page.tsx (0 hunks)
💤 Files with no reviewable changes (1)
  • app/page.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/components/chat.tsx
🔇 Additional comments (9)
app/mcp/actions.ts (4)

334-341: Handle missing configuration file gracefully

In getMcpConfigFromFile, if the configuration file is missing (e.g., on the first run), the error is logged, which might be confusing for users.

This issue was previously noted. Consider checking if the error is due to the file not existing (ENOENT) and initialize with a default configuration without logging an error.


345-351: Use atomic writes to prevent configuration file corruption

When updating the MCP configuration, writing directly to the file could lead to corruption if the process is interrupted.

As previously suggested, consider implementing atomic file writes using temporary files and renaming:

async function updateMcpConfig(config: McpConfigData): Promise<void> {
  try {
+   const tempPath = `${CONFIG_PATH}.tmp`;
+   await fs.writeFile(tempPath, JSON.stringify(config, null, 2));
+   await fs.rename(tempPath, CONFIG_PATH);
  } catch (error) {
+   // Clean up temp file if it exists
+   try {
+     await fs.unlink(`${CONFIG_PATH}.tmp`);
+   } catch {
+     // Ignore cleanup errors
+   }
    throw error;
  }
}

316-331: Add request validation to ensure correct execution

The executeMcpAction function should validate the request structure to prevent potential errors during execution.

This was highlighted earlier. Ensure that the request contains the necessary properties:

export async function executeMcpAction(
  clientId: string,
  request: McpRequestMessage,
) {
  try {
+   // Validate request structure
+   if (!request || typeof request !== 'object') {
+     throw new Error('Invalid request format');
+   }
+   if (!request.action || typeof request.action !== 'string') {
+     throw new Error('Missing or invalid action in request');
+   }

    const client = clientsMap.get(clientId);
    if (!client?.client) {
      throw new Error(`Client ${clientId} not found`);
    }
    logger.info(`Executing request for [${clientId}]`);
    return await executeRequest(client.client, request);
  } catch (error) {
    logger.error(`Failed to execute request for [${clientId}]: ${error}`);
    throw error;
  }
}

291-313: 🛠️ Refactor suggestion

Ensure all clients are restarted even if some fail

In restartAllClients, a failure in one client could prevent other clients from restarting due to the synchronous for loops.

Refactor the function to handle client restarts asynchronously and independently:

      // 关闭所有客户端
-     for (const client of clientsMap.values()) {
-       if (client.client) {
-         await removeClient(client.client);
-       }
-     }
+     await Promise.allSettled(
+       Array.from(clientsMap.values()).map(async (client) => {
+         if (client.client) {
+           try {
+             await removeClient(client.client);
+           } catch (error) {
+             logger.error(`Failed to remove client: ${error}`);
+           }
+         }
+       })
+     );

      // 清空状态
      clientsMap.clear();

      // 重新初始化
      const config = await getMcpConfigFromFile();
-     for (const [clientId, serverConfig] of Object.entries(config.mcpServers)) {
-       await initializeSingleClient(clientId, serverConfig);
-     }
+     await Promise.all(
+       Object.entries(config.mcpServers).map(([clientId, serverConfig]) =>
+         initializeSingleClient(clientId, serverConfig)
+       )
+     );

Likely invalid or redundant comment.

Dockerfile (1)

45-45: Verify the existence of mcp_config.json.

The COPY command assumes mcp_config.json exists in the builder stage. If this file is missing, the build will fail.

.env.template (1)

10-14: LGTM!

The documentation for the ENABLE_MCP environment variable is clear, follows the existing pattern, and correctly specifies the default value and usage.

app/components/home.tsx (1)

78-83: LGTM!

The dynamic import for McpMarketPage follows the existing pattern and includes proper loading state handling.

app/components/sidebar.tsx (1)

267-277: LGTM!

The conditional rendering of the MCP button is well-implemented with proper icon, text, and navigation handling.

app/components/mcp-market.tsx (1)

76-94: 🛠️ Refactor suggestion

Improve error handling in loadPresetServers.

The function uses console.error and could benefit from better error handling.

Apply this diff:

 const loadPresetServers = async () => {
   if (!mcpEnabled) return;
   try {
     setLoadingPresets(true);
     const response = await fetch("https://nextchat.club/mcp/list");
     if (!response.ok) {
-      throw new Error("Failed to load preset servers");
+      throw new Error(`Failed to load preset servers: ${response.statusText}`);
     }
     const data = await response.json();
+    if (!data?.data) {
+      throw new Error("Invalid server response format");
+    }
     setPresetServers(data?.data ?? []);
   } catch (error) {
-    console.error("Failed to load preset servers:", error);
     showToast("Failed to load preset servers");
   } finally {
     setLoadingPresets(false);
   }
 };

Likely invalid or redundant comment.

Comment on lines +638 to +640
Mcp: {
Name: "MCP",
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Add comprehensive localization for MCP-related UI elements

The verification revealed that most MCP-related strings are not properly localized. Please add the following keys to the Mcp object in the locale files:

  • Market page elements:
    • app/components/mcp-market.tsx: "MCP Market", "Search MCP Server", "servers configured"
    • app/components/mcp-market.tsx: Status messages like "Creating MCP client...", "Starting server...", "Stopping server..."
  • Error messages:
    • app/store/chat.ts: "MCP execution failed"
    • app/components/mcp-market.tsx: "Failed to load preset servers"
  • Button labels and tooltips in the market interface
🔗 Analysis chain

Verify comprehensive localization coverage for MCP feature.

As this is a WIP PR implementing the Multi-Channel Protocol system, ensure that all user-facing strings related to MCP functionality (such as error messages, tooltips, or configuration options) are properly localized.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for potential unlocalized MCP-related strings in the codebase
echo "Searching for MCP-related strings that might need localization..."
rg -i "mcp" --type ts --type tsx --type js --type jsx -g '!app/locales/*' -g '!*test*'

Length of output: 255


Script:

#!/bin/bash
# Search for MCP-related strings in TypeScript and JavaScript files
echo "Searching for MCP-related strings in source files..."
rg -i "mcp" --type ts --type js -g '!app/locales/*' -g '!*test*' -g '!*.d.ts'

# Search specifically for string literals containing MCP
echo -e "\nSearching for potential string literals containing MCP..."
ast-grep --pattern 'StringLiteral: /.*[Mm][Cc][Pp].*/'

# Search for potential React components or features related to MCP
echo -e "\nSearching for MCP-related components or features..."
rg -i "mcp" --type ts --type js -g '!app/locales/*' -g '!*test*' -A 2 -B 2

Length of output: 54077

Comment on lines +35 to +36
const serverConfig = getServerSideConfig();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure server-side code is not executed on the client

The usage of getServerSideConfig inside a component may cause issues if the component is rendered on the client side.

Since getServerSideConfig accesses server-side environment variables, ensure that RootLayout is a server component or modify the code to prevent client-side execution.


COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static
COPY --from=builder /app/.next/server ./.next/server

RUN mkdir -p /app/app/mcp && chmod 777 /app/app/mcp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Restrict directory permissions for security.

Setting 777 permissions (read, write, execute for all users) on the /app/app/mcp directory is too permissive and poses a security risk. Consider using more restrictive permissions.

Apply this diff to use more restrictive permissions:

-RUN mkdir -p /app/app/mcp && chmod 777 /app/app/mcp
+RUN mkdir -p /app/app/mcp && chown node:node /app/app/mcp && chmod 755 /app/app/mcp
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
RUN mkdir -p /app/app/mcp && chmod 777 /app/app/mcp
RUN mkdir -p /app/app/mcp && chown node:node /app/app/mcp && chmod 755 /app/app/mcp

Comment on lines +246 to +258
const initMcp = async () => {
try {
const enabled = await isMcpEnabled();
if (enabled) {
console.log("[MCP] initializing...");
await initializeMcpSystem();
console.log("[MCP] initialized");
}
} catch (err) {
console.error("[MCP] failed to initialize:", err);
}
};
initMcp();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove console logs and improve error handling.

The initialization code includes console logs and could benefit from better error handling.

Apply this diff to improve the code:

 const initMcp = async () => {
   try {
     const enabled = await isMcpEnabled();
     if (enabled) {
-      console.log("[MCP] initializing...");
       await initializeMcpSystem();
-      console.log("[MCP] initialized");
     }
   } catch (err) {
-    console.error("[MCP] failed to initialize:", err);
+    showToast(
+      err instanceof Error
+        ? `Failed to initialize MCP: ${err.message}`
+        : "Failed to initialize MCP"
+    );
   }
 };

Committable suggestion skipped: line range outside the PR's diff.

Comment on lines +231 to +239
useEffect(() => {
// 检查 MCP 是否启用
const checkMcpStatus = async () => {
const enabled = await isMcpEnabled();
setMcpEnabled(enabled);
console.log("[SideBar] MCP enabled:", enabled);
};
checkMcpStatus();
}, []);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Remove console logs and add missing dependency.

The effect includes console logs and is missing mcpEnabled in its dependency array.

Apply this diff to improve the code:

 useEffect(() => {
-  // 检查 MCP 是否启用
   const checkMcpStatus = async () => {
     const enabled = await isMcpEnabled();
     setMcpEnabled(enabled);
-    console.log("[SideBar] MCP enabled:", enabled);
     if (!enabled) {
       navigate(Path.Home);
     }
   };
   checkMcpStatus();
-}, [navigate]);
+}, [navigate, mcpEnabled]);

Committable suggestion skipped: line range outside the PR's diff.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
app/mcp/actions.ts (1)

337-352: 🛠️ Refactor suggestion

Add request validation in executeMcpAction

In executeMcpAction, the request object is used without validation, which could lead to unexpected errors or security vulnerabilities. Consider validating the structure and content of the request parameter to ensure it meets the expected format.

Apply this change:

export async function executeMcpAction(
  clientId: string,
  request: McpRequestMessage,
) {
  try {
+   // Validate request structure
+   if (!request || typeof request !== 'object') {
+     throw new Error('Invalid request format');
+   }
+   if (!request.action || typeof request.action !== 'string') {
+     throw new Error('Missing or invalid action in request');
+   }
+
    const client = clientsMap.get(clientId);
    if (!client?.client) {
      throw new Error(`Client ${clientId} not found`);
    }
    logger.info(`Executing request for [${clientId}]`);
    return await executeRequest(client.client, request);
  } catch (error) {
    logger.error(`Failed to execute request for [${clientId}]: ${error}`);
    throw error;
  }
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bc71ae2 and bfeea4e.

📒 Files selected for processing (4)
  • app/components/mcp-market.module.scss (1 hunks)
  • app/components/mcp-market.tsx (1 hunks)
  • app/mcp/actions.ts (1 hunks)
  • app/mcp/types.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/mcp/types.ts
🔇 Additional comments (6)
app/mcp/actions.ts (2)

355-363: Handle missing configuration file gracefully

In getMcpConfigFromFile, when the configuration file is missing (e.g., on the first run), it logs an error and returns the default configuration. Instead, consider checking if the error is due to the file not existing (ENOENT) and avoid logging an error in that case. This provides a smoother user experience.

Apply this change:

} catch (error) {
-   logger.error(`Failed to load MCP config, using default config: ${error}`);
-   return DEFAULT_MCP_CONFIG;
+   if (error.code === 'ENOENT') {
+     logger.warn("MCP config file not found, using default configuration.");
+     return DEFAULT_MCP_CONFIG;
+   } else {
+     logger.error(`Failed to load MCP config: ${error}`);
+     throw error;
+   }
}

366-372: Implement atomic file writes for configuration updates

When updating the MCP configuration file in updateMcpConfig, there is a risk of file corruption if the write operation is interrupted. Consider using a temporary file and an atomic rename operation to ensure the configuration file remains consistent.

Apply this change:

async function updateMcpConfig(config: McpConfigData): Promise<void> {
  try {
+   const tempPath = `${CONFIG_PATH}.tmp`;
+   await fs.writeFile(tempPath, JSON.stringify(config, null, 2));
+   await fs.rename(tempPath, CONFIG_PATH);
  } catch (error) {
+   // Clean up temp file if it exists
+   try {
+     await fs.unlink(`${CONFIG_PATH}.tmp`);
+   } catch {
+     // Ignore cleanup errors
+   }
    throw error;
  }
}
app/components/mcp-market.module.scss (1)

269-274: Enhance focus visibility for better accessibility

The focus styles on input elements can be improved to enhance keyboard navigation and accessibility. Consider adjusting the box-shadow and adding outline-offset to make focused elements more noticeable.

Apply this change:

&:focus {
  background-color: var(--white);
  border-color: var(--primary);
  outline: none;
-  box-shadow: 0 0 0 2px var(--primary-10);
+  box-shadow: 0 0 0 3px var(--primary-20);
+  outline: 2px solid transparent;
+  outline-offset: 2px;
}
app/components/mcp-market.tsx (3)

47-47: Replace 'any' with specific types in userConfig

Using any reduces type safety and can lead to runtime errors. Specify the expected types to enhance type checking.

Apply this change:

- const [userConfig, setUserConfig] = useState<Record<string, any>>({});
+ const [userConfig, setUserConfig] = useState<Record<string, string | string[]>>({});

676-682: Improve accessibility of the search input

Add ARIA attributes to the search input to enhance accessibility for users relying on assistive technologies.

Apply this change:

<input
  type="text"
  className={styles["search-bar"]}
  placeholder={"Search MCP Server"}
  autoFocus
  onInput={(e) => setSearchText(e.currentTarget.value)}
+ aria-label="Search MCP servers"
+ role="searchbox"
/>

691-714: Enhance modal accessibility

Include appropriate ARIA attributes in the modal to improve accessibility for assistive technologies.

Apply this change:

<Modal
  title={`Configure Server - ${editingServerId}`}
  onClose={() => !isLoading && setEditingServerId(undefined)}
+ role="dialog"
+ aria-modal="true"
+ aria-labelledby="modal-title"
  actions={[
    // Actions...
  ]}
>
+ <h2 id="modal-title" className="sr-only">
+   Configure Server - {editingServerId}
+ </h2>
  <List>{renderConfigForm()}</List>
</Modal>

Comment on lines +83 to +87
export async function getAvailableClientsCount() {
let count = 0;
clientsMap.forEach((map) => !map.errorMsg && count++);
return count;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Ensure accurate count of available clients

In getAvailableClientsCount, clients with errorMsg set to null are counted as available. However, during initialization, errorMsg is null, but the client may not yet be fully initialized. To accurately count only active clients, consider checking if map.client is not null and errorMsg is null.

Apply this diff to fix the issue:

export async function getAvailableClientsCount() {
  let count = 0;
- clientsMap.forEach((map) => !map.errorMsg && count++);
+ clientsMap.forEach((map) => map.client && !map.errorMsg && count++);
  return count;
}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export async function getAvailableClientsCount() {
let count = 0;
clientsMap.forEach((map) => !map.errorMsg && count++);
return count;
}
export async function getAvailableClientsCount() {
let count = 0;
clientsMap.forEach((map) => map.client && !map.errorMsg && count++);
return count;
}

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
app/constant.ts (1)

277-392: Consider improving the system template structure and examples.

While the template is comprehensive, there are a few areas for improvement:

  1. The example section mixes Chinese and English content
  2. The error examples contain excessive exclamation marks
  3. The formatting could be more consistent

Consider these improvements:

-  follwing is the wrong! mcp json example:
+  Following are examples of incorrect MCP JSON format:

-  This is wrong because the method is not tools/call.!!!!!!!!!!!
+  This is incorrect because the method is not "tools/call".

-  please follow the format strictly ONLY use tools/call method!!!!!!!!!!!
+  Please strictly follow the format and ONLY use the "tools/call" method.

-      "content": "为什么数学书总是感到忧伤?因为它有太多的问题。"
+      "content": "Why do math books look sad? Because they have too many problems."
app/store/chat.ts (1)

Line range hint 403-429: Consider adding validation for MCP response content.

While the implementation handles MCP responses correctly, it would be beneficial to add validation for the response content.

Consider adding validation:

 async onUserInput(
   content: string,
   attachImages?: string[],
   isMcpResponse?: boolean,
 ) {
+  if (isMcpResponse && !content.trim()) {
+    console.warn("[MCP] Empty response content");
+    return;
+  }
   const session = get().currentSession();
   const modelConfig = session.mask.modelConfig;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 611e97e and a3d3ce3.

📒 Files selected for processing (8)
  • README_CN.md (3 hunks)
  • app/components/chat.tsx (15 hunks)
  • app/components/sidebar.tsx (6 hunks)
  • app/config/server.ts (2 hunks)
  • app/constant.ts (3 hunks)
  • app/locales/cn.ts (1 hunks)
  • app/locales/en.ts (1 hunks)
  • app/store/chat.ts (11 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • app/locales/en.ts
  • README_CN.md
  • app/locales/cn.ts
  • app/config/server.ts
  • app/components/sidebar.tsx
  • app/components/chat.tsx
🔇 Additional comments (8)
app/constant.ts (3)

52-52: LGTM!

The new path follows the existing naming convention and is appropriately placed in the enum.


94-94: LGTM!

The new store key follows the existing naming convention and is appropriately placed in the enum.


270-275: LGTM!

The template is well-structured and provides clear placeholders for dynamic content.

app/store/chat.ts (5)

Line range hint 1-39: LGTM!

The imports are well-organized and include all necessary dependencies for the MCP functionality.


64-64: LGTM!

The isMcpResponse flag is appropriately added to the ChatMessage type.


201-220: Add error handling and validation in getMcpSystemPrompt.

The implementation needs improvements in error handling and validation as previously suggested.


395-399: LGTM!

The MCP JSON check is appropriately added to the message processing flow.


817-845: Address security concerns in MCP JSON handling.

The implementation needs security improvements as previously suggested.

@Leizhenpeng Leizhenpeng merged commit 4cad553 into main Jan 19, 2025
1 of 2 checks passed
chatnext pushed a commit to chatnext/NextChat-test that referenced this pull request Jan 22, 2025
…at-mcp"

This reverts commit 4cad553, reversing
changes made to 93652db.
eric19960304 added a commit to eric19960304/crossgpt that referenced this pull request Feb 21, 2025
commit f5f3ce94f63bceadff24ca1beff3ae85d142f92e
Author: RiverRay <[email protected]>
Date:   Fri Feb 21 08:56:43 2025 +0800

    Update README.md

commit 2b5f6003086f65f5361ccfc5dc83242f2ca813b8
Author: RiverRay <[email protected]>
Date:   Fri Feb 21 08:55:40 2025 +0800

    Update README.md

commit b96610711763d5b5e64d138f6599008c0065accc
Merge: 377480b4 90827fc5
Author: RiverRay <[email protected]>
Date:   Mon Feb 17 22:58:01 2025 +0800

    Merge pull request #6235 from DBCDK/danish-locale

    Translation to danish

commit 377480b448798488db5ef03f4d5c44d2d930693c
Merge: 8bd0d6a1 12863f52
Author: river <[email protected]>
Date:   Sun Feb 16 10:50:07 2025 +0800

    Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web

commit 8bd0d6a1a7abccc736769b9f2b2b9c9ee75b81a8
Author: river <[email protected]>
Date:   Sun Feb 16 10:48:54 2025 +0800

    chore: Update NextChatAI domain from nextchat.dev to nextchat.club

commit 90827fc593f2e756264c0d309e638491105b669b
Author: Rasmus Erik Voel Jensen <[email protected]>
Date:   Sat Feb 15 13:08:58 2025 +0100

    danish rewording / improved button label

commit 008e339b6d1c227c47a9cb4877ba8bb064f41043
Author: Rasmus Erik Voel Jensen <[email protected]>
Date:   Sat Feb 15 12:52:44 2025 +0100

    danish locale

commit 12863f52131bba9d75b29038970c9293f3b54cb5
Merge: 48cd4b11 cf140d42
Author: RiverRay <[email protected]>
Date:   Thu Feb 13 14:53:47 2025 +0800

    Merge pull request #6204 from bestsanmao/ali_bytedance_reasoning_content

    add 3 type of reasoning_content support (+deepseek-r1@OpenAI @Alibaba @ByteDance), parse <think></think> from SSE

commit cf140d422863e313ad1609dfd33fd19ea5463ff3
Merge: 476d946f 48cd4b11
Author: suruiqiang <[email protected]>
Date:   Wed Feb 12 17:54:50 2025 +0800

    Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web into ali_bytedance_reasoning_content

commit 476d946f961a551ffedc7734dcce28faa7dc30fe
Author: suruiqiang <[email protected]>
Date:   Wed Feb 12 17:49:54 2025 +0800

    fix bug (trim eats space or \n mistakenly), optimize timeout by model

commit 97142583224faa28e7cdd43eba75b77828f280af
Author: suruiqiang <[email protected]>
Date:   Tue Feb 11 18:57:16 2025 +0800

    support deepseek-r1@OpenAI's reasoning_content, parse <think></think> from stream

commit 48cd4b11b5dd14b333350a80be597a2b98391d1c
Merge: 77c78b23 18fa2cc3
Author: RiverRay <[email protected]>
Date:   Tue Feb 11 18:37:47 2025 +0800

    Merge pull request #6190 from siliconflow/refine-emoji-siliconflow

    Fix model icon on SiliconFlow

commit 77c78b230a8e0a06f7a6fb8d09837cf5056c0a8c
Merge: b44686b8 2137aa65
Author: RiverRay <[email protected]>
Date:   Tue Feb 11 18:37:22 2025 +0800

    Merge pull request #6193 from siliconflow/get-models-siliconflow

    Model listing of SiliconFlow

commit b44686b887c9f9f6495b67c4dda77ed5111c30b7
Merge: 34bdd4b9 9f91c2d0
Author: RiverRay <[email protected]>
Date:   Tue Feb 11 18:36:50 2025 +0800

    Merge pull request #6189 from bestsanmao/bug_fix

    fix avatar for export message preview and saved image

commit 34bdd4b945bea213d660fec4c15796d70b2c137b
Merge: a029b433 86f86962
Author: RiverRay <[email protected]>
Date:   Tue Feb 11 18:35:02 2025 +0800

    Merge pull request #6194 from siliconflow/vl-support-on-sf

    Support VLM on SiliconFlow

commit b0758cccde8709af7fa31aed8c019029c97be82b
Author: suruiqiang <[email protected]>
Date:   Tue Feb 11 16:08:30 2025 +0800

    optimization

commit 98a11e56d2c55d7d89dfc4c8905045781863bf98
Author: suruiqiang <[email protected]>
Date:   Tue Feb 11 12:46:46 2025 +0800

    support alibaba and bytedance's reasoning_content

commit 86f86962fb0725b888cee6ebd9eb9f818a0c9cee
Author: Shenghang Tsai <[email protected]>
Date:   Mon Feb 10 13:37:48 2025 +0800

    Support VLM on SiliconFlow

commit 2137aa65bfaeda33bdbfad7f1ae36bfdde8c9edf
Author: Shenghang Tsai <[email protected]>
Date:   Mon Feb 10 11:03:49 2025 +0800

    Model listing of SiliconFlow

commit 18fa2cc30d96fbb452efd9226db7ca6021cacb3e
Author: Shenghang Tsai <[email protected]>
Date:   Sun Feb 9 18:49:26 2025 +0800

    fix model icon on siliconflow

commit 0bfc6480855640032ec3593960b434fc5e1c1de5
Author: Shenghang Tsai <[email protected]>
Date:   Sun Feb 9 18:47:57 2025 +0800

    fix model icon on siliconflow

commit 9f91c2d05c21c7fea604a88a0974679a07293c81
Author: suruiqiang <[email protected]>
Date:   Sun Feb 9 16:52:46 2025 +0800

    fix avatar for export message preview and saved image

commit a029b4330b89f8f2d1258e46fa68ba87c998a745
Merge: c2edfec1 2842b264
Author: RiverRay <[email protected]>
Date:   Sun Feb 9 11:05:43 2025 +0800

    Merge pull request #6188 from ChatGPTNextWeb/Leizhenpeng-patch-4

    Update LICENSE

commit 2842b264e06b08de9cfdcb84982ee6571fa45881
Author: RiverRay <[email protected]>
Date:   Sun Feb 9 11:05:32 2025 +0800

    Update LICENSE

commit c2edfec16fc97446b58149312706f1539e60fc58
Merge: 6406ac99 97a4aafc
Author: RiverRay <[email protected]>
Date:   Sun Feb 9 11:03:44 2025 +0800

    Merge pull request #6172 from bestsanmao/bug_fix

    fix several bugs

commit 6406ac99a30659abd7a93e47a5faa2def9464f46
Merge: c6199dbf d8f533e1
Author: RiverRay <[email protected]>
Date:   Sun Feb 9 11:02:13 2025 +0800

    Merge pull request #6175 from itsevin/main

    Add other Xai model

commit 97a4aafc9276760443c2044bad5c454c7d9435a4
Merge: 1ae5fdbf c6199dbf
Author: suruiqiang <[email protected]>
Date:   Sun Feb 9 09:46:07 2025 +0800

    Merge remote-tracking branch 'remotes/origin/main' into bug_fix

commit d8f533e1f35b75905ef822cbc50e62c3f228b148
Merge: fdbaddde c6199dbf
Author: GH Action - Upstream Sync <[email protected]>
Date:   Sun Feb 9 01:22:47 2025 +0000

    Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web

commit c6199dbf9f1a9f729eebff28944b59d3bcc2c6a4
Merge: 4273aa08 acf75ce6
Author: RiverRay <[email protected]>
Date:   Sat Feb 8 23:40:39 2025 +0800

    Merge pull request #6186 from siliconflow/fix-truc-of-reasoning-model

    Fix formatting of reasoning model on SiliconFlow

commit 4273aa0803b5b7267730b77995c55fd7f674b0d4
Merge: bf265d33 2a3996e0
Author: RiverRay <[email protected]>
Date:   Sat Feb 8 23:39:49 2025 +0800

    Merge pull request #6185 from siliconflow/larger_timeout_for_siliconflow

    Larger timeout for SiliconFlow

commit acf75ce68f7152972fe5924b4880b3ae06c0ca65
Author: Shenghang Tsai <[email protected]>
Date:   Sat Feb 8 16:34:17 2025 +0800

    Remove unnecessary trimming

commit 1ae5fdbf013349a2c32e6083b41500cbf2c4000d
Author: suruiqiang <[email protected]>
Date:   Sat Feb 8 16:15:10 2025 +0800

    mini optimizations

commit 2a3996e0d66e41a99bfd4373c2bd9dec4d78652a
Author: Shenghang Tsai <[email protected]>
Date:   Sat Feb 8 14:38:12 2025 +0800

    Update siliconflow.ts

commit fdbaddde37165b293ba7d246108ea1a5610b92da
Merge: c4e9cb03 bf265d33
Author: GH Action - Upstream Sync <[email protected]>
Date:   Sat Feb 8 01:16:56 2025 +0000

    Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web

commit d74f79e9c5ee36fa9c3a59f8390a444857417b1e
Merge: a5a97682 bf265d33
Author: suruiqiang <[email protected]>
Date:   Sat Feb 8 08:29:34 2025 +0800

    Merge remote-tracking branch 'remotes/origin/HEAD' into bug_fix

commit c4e9cb03a92751b37ec0b9615ef5ec056fa20bde
Author: itsevin <[email protected]>
Date:   Fri Feb 7 20:29:21 2025 +0800

    Add Xai model

commit bf265d33759dfada0d91248cbcb5ae22326e745f
Merge: 17f391d9 51384ddc
Author: RiverRay <[email protected]>
Date:   Fri Feb 7 20:25:20 2025 +0800

    Merge pull request #6164 from ZhangYichi-ZYc/main

    Fix: Set consistent fill color for OpenAI/MoonShot/Grok SVG to prevent color inversion in dark mode

commit 17f391d929a0281f67e22d87a95f06ed9c811cf8
Merge: 78186c27 e5e5fde9
Author: RiverRay <[email protected]>
Date:   Fri Feb 7 20:23:47 2025 +0800

    Merge pull request #6158 from dupl/main

    update the lastest Gemini models

commit 78186c27fb70fdeeafb8a9ac6ab7a3b43bb9c8e0
Merge: add9ca20 a780b39c
Author: RiverRay <[email protected]>
Date:   Fri Feb 7 20:23:01 2025 +0800

    Merge pull request #6168 from xiexin12138/fix-env

    Fix: 补充 env 中硅基流动的环境变量;追加硅基流动 2 个支持的付费模型

commit a5a976824591a7e2c228dbb257616b98fd7a53ed
Author: suruiqiang <[email protected]>
Date:   Fri Feb 7 16:34:14 2025 +0800

    change request timeout for thinking mode

commit 3fe55b4f7ff1791cf6e8c5d9da02b69a240e98a8
Author: suruiqiang <[email protected]>
Date:   Fri Feb 7 16:20:07 2025 +0800

    fix bug that gemini has multiple candidates part

commit f156430cc5f9451618b13e6432148d1d0dd35c5c
Author: suruiqiang <[email protected]>
Date:   Fri Feb 7 16:18:15 2025 +0800

    fix emoji issue for doubao and glm's congview & congvideox

commit f30c6a4348fb25fead1d1ba4f4ff6717a45496fb
Author: suruiqiang <[email protected]>
Date:   Fri Feb 7 16:14:19 2025 +0800

    fix doubao and grok not upload image

commit a780b39c17a271eb44421ac2f027fcf91c3b77cf
Author: xiexin12138 <[email protected]>
Date:   Fri Feb 7 15:43:50 2025 +0800

    fix: 补充硅基流动对 DeepSeek 支持的付费模型

commit 1010db834ce52f6a832bf50d3645527f3b42697e
Author: xiexin12138 <[email protected]>
Date:   Fri Feb 7 15:41:40 2025 +0800

    fix: 补充硅基流动的 env 环境变量

commit 51384ddc5feff6ca31028c77cf6b17b751a0ab24
Author: ZhangYichi <[email protected]>
Date:   Fri Feb 7 11:13:22 2025 +0800

    Fix: Set consistent fill color for OpenAI/MoonShot/Grok SVG to prevent color inversion in dark mode

commit e5e5fde924a7598a6c447c079cce7337294b9d81
Author: dupl <[email protected]>
Date:   Fri Feb 7 06:50:31 2025 +0800

    update the lastest Gemini models

commit add9ca200cf91e467c2d6b770e4a8f140aff18e8
Merge: 28cbe56c 5225a6e1
Author: RiverRay <[email protected]>
Date:   Thu Feb 6 18:08:08 2025 +0800

    Merge pull request #6144 from Eric-2369/add-more-llm-icons

    feat: add more llm icons

commit 5225a6e1921d170803ab11aa8ba09957cf0b678b
Author: Eric-2369 <[email protected]>
Date:   Wed Feb 5 12:34:00 2025 +0800

    feat: add more llm icons

commit 28cbe56cec390c2309a3995b300c8d5aa1387c0a
Merge: bb4832e6 ad9ab9d4
Author: RiverRay <[email protected]>
Date:   Tue Feb 4 21:29:02 2025 +0800

    Merge pull request #6141 from siliconflow/provider_silicon

    New provider SiliconFlow and Its Latest DeekSeek Models

commit ad9ab9d45afa384718a59bce23d9b70e3e8ed08a
Author: Shenghang Tsai <[email protected]>
Date:   Tue Feb 4 15:02:18 2025 +0800

    New provider SiliconFlow and Its Latest DeekSeek Models

    Update README.md

    Update constant.ts

    Update README_CN.md

commit bb4832e6e71626184c339cce86eab94dbc3f8a59
Merge: 32b60909 39b3487e
Author: RiverRay <[email protected]>
Date:   Tue Feb 4 09:38:04 2025 +0800

    Merge pull request #6129 from MonadMonAmi/update_knowledge_cutoff_date

    chore: add knowledge cut off dates for o1 and o3

commit 39b3487ea0f62065ffbe5f743c298af8247e9834
Merge: 2e7cac32 32b60909
Author: RiverRay <[email protected]>
Date:   Tue Feb 4 09:37:55 2025 +0800

    Merge branch 'main' into update_knowledge_cutoff_date

commit 32b60909ae37948aca97a0fbec218372086e938f
Merge: 5db6775c 4c4d44e2
Author: RiverRay <[email protected]>
Date:   Tue Feb 4 09:35:43 2025 +0800

    Merge pull request #6132 from RetiredQQ/main

    temporary fix for o3-mini

commit 5db6775cb85917c99d171905c38efa4a368bb873
Merge: b6881c77 92f57fb1
Author: RiverRay <[email protected]>
Date:   Tue Feb 4 09:34:43 2025 +0800

    Merge pull request #6134 from zcong1993/main

    fix: fix isModelNotavailableInServer logic for bytedance models

commit b6881c77978b50debfd3907a863f2481e51ff299
Merge: 9943a522 60fa3580
Author: RiverRay <[email protected]>
Date:   Tue Feb 4 09:33:13 2025 +0800

    Merge pull request #6127 from dupl/main

    add gemini-2.0-flash-thinking-exp, gemini-2.0-flash-thinking-exp-01-21

commit 9943a52295e36b0c296110f31643090f5fe0bb35
Author: RiverRay <[email protected]>
Date:   Tue Feb 4 09:31:16 2025 +0800

    Update README.md

commit 1db4d25370d5754576c2bddc29ee75c6869b2696
Author: RiverRay <[email protected]>
Date:   Tue Feb 4 09:29:56 2025 +0800

    Update README.md

commit 92f57fb18fe40e73a425842747d4b5654493f275
Author: zcong1993 <[email protected]>
Date:   Mon Feb 3 16:58:42 2025 +0800

    fix: fix isModelNotavailableInServer logic for bytedance models

commit 4c4d44e2f831ec3296bbfd9f3c9e8b201e6bf18d
Author: Sky <[email protected]>
Date:   Sun Feb 2 21:45:30 2025 +0000

    fix

commit 8f12beb8f0b65d9b3de009348b0a8b2397e5574c
Author: Sky <[email protected]>
Date:   Sun Feb 2 21:43:30 2025 +0000

    support o3-mini

commit 2e7cac32185e52f648d30a76a61474951295c0be
Author: AndrewS <[email protected]>
Date:   Sun Feb 2 19:44:53 2025 +0100

    chore: add knowledge cut off dates for o1 and o3

commit 60fa358010125894dc85f19618081040eccce15c
Author: dupl <[email protected]>
Date:   Sun Feb 2 23:27:45 2025 +0800

    typo: OpanAI -> OpenAI

commit 034b7d4655c55ecd5a8e6abd5a130356e4f6b38a
Author: dupl <[email protected]>
Date:   Sun Feb 2 23:11:07 2025 +0800

    add gemini-2.0-flash-thinking-exp, gemini-2.0-flash-thinking-exp-01-21

commit 1e20b64048769b4a11ec4691670a1a34711d962e
Merge: 3ef59930 4f28fca5
Author: RiverRay <[email protected]>
Date:   Sun Feb 2 20:57:21 2025 +0800

    Merge pull request #6121 from ChatGPTNextWeb/feat/support-openai-o3-mini

    feat(model): add support for OpenAI o3-mini model

commit 4f28fca506980306c7d5810d4b6c9365503dce7f
Author: Kadxy <[email protected]>
Date:   Sat Feb 1 15:02:06 2025 +0800

    feat: Support OpenAI o3-mini

commit 3ef599308512b41134a67a2087111e729b25d35c
Merge: 31e52cb4 09ad7c18
Author: RiverRay <[email protected]>
Date:   Fri Jan 31 08:18:47 2025 +0800

    Merge pull request #6119 from ChatGPTNextWeb/Leizhenpeng-patch-3

    Update README.md

commit 09ad7c187556da8af88fa1adf42bc475e22e50eb
Author: RiverRay <[email protected]>
Date:   Fri Jan 31 08:18:13 2025 +0800

    Update README.md

commit 31e52cb47e61c4aa39e3f66f94ed0018968f5bd9
Author: RiverRay <[email protected]>
Date:   Fri Jan 31 06:53:39 2025 +0800

    更新 README.md

commit 9a69c5bd7c6bd496e3920f9d87bc8899737c25f2
Merge: c41e86fa be645aab
Author: RiverRay <[email protected]>
Date:   Fri Jan 31 06:48:00 2025 +0800

    Merge pull request #6118 from ChatGPTNextWeb/feat/issue-6104-deepseek-reasoning-content

commit be645aab37121ed488ce0c0e41c6d41a0e32c39d
Author: Kadxy <[email protected]>
Date:   Fri Jan 31 00:59:03 2025 +0800

    fix: revert unintended changes

commit c41e86faa6aea948811770d1871f4ca034c6fefd
Merge: 553b8c9f 143be69a
Author: RiverRay <[email protected]>
Date:   Fri Jan 31 00:52:18 2025 +0800

    Merge pull request #6116 from ChatGPTNextWeb/feat/issue-6104-deepseek-reasoning-content

    Support DeepSeek API streaming reasoning content

commit 143be69a7ffc68f5498328152c6eb6aaa67294fe
Author: river <[email protected]>
Date:   Fri Jan 31 00:50:03 2025 +0800

    chore: remove log

commit 63b7626656d2d8a221aa9edb491bf6912460e449
Author: river <[email protected]>
Date:   Fri Jan 31 00:49:09 2025 +0800

    chore: change md

commit dabb7c70d5e4438b3f6f8cd67ed729c966d3da37
Author: Kadxy <[email protected]>
Date:   Fri Jan 31 00:30:08 2025 +0800

    feat:  Remove reasoning_contentfor DeepSeek API messages

commit c449737127dcdde4547a8b0caa6070ab1c17b45c
Author: Kadxy <[email protected]>
Date:   Fri Jan 31 00:07:52 2025 +0800

    feat: Support DeepSeek API streaming with thinking mode

commit 553b8c9f284bff6ec059b4d69f3f91c10105fbc0
Author: RiverRay <[email protected]>
Date:   Mon Jan 27 13:05:17 2025 +0800

    Update .env.template

commit 19314793b8d379cb9936b6ba1205bd701f48c320
Merge: 2f9cb5a6 86801829
Author: river <[email protected]>
Date:   Mon Jan 27 12:55:31 2025 +0800

    Merge branch 'bestsanmao-bug_fix'

commit 86801829215e8efd5f935eb8221b104a6456c177
Author: river <[email protected]>
Date:   Mon Jan 27 12:48:59 2025 +0800

    feat: Add DeepSeek API key and fix MCP environment variable parsing

commit 2173c82bb55e1cd7c7bf994dcb6e0d7484c71daf
Author: suruiqiang <[email protected]>
Date:   Thu Jan 23 18:47:22 2025 +0800

    add deepseek-reasoner, and change deepseek's summary model to deepseek-chat

commit 0d5e66a9aeca9dd454df46fbdd1f12d69ba9b5a2
Author: suruiqiang <[email protected]>
Date:   Thu Jan 23 18:24:38 2025 +0800

    not insert mcpSystemPrompt if not ENABLE_MCP

commit 2f9cb5a68f59c512508a341f76b30f807d1e17fe
Merge: 6a862372 55cacfb7
Author: RiverRay <[email protected]>
Date:   Wed Jan 22 21:40:37 2025 +0800

    Merge pull request #6084 from ChatGPTNextWeb/temp-fix

    fix: missing mcp_config.json files required for building

commit 55cacfb7e22034f15bb3541813ad6f3f621f2fcc
Author: Kadxy <[email protected]>
Date:   Wed Jan 22 21:28:29 2025 +0800

    fix: missing files required for building

commit 6a862372f7e4b1d8b188fd97d016081dc371cbdb
Merge: b2b6fd81 81bd83eb
Author: RiverRay <[email protected]>
Date:   Wed Jan 22 13:11:11 2025 +0800

    Merge pull request #6082 from ChatGPTNextWeb/Leizhenpeng-patch-2

    Update README_CN.md

commit 81bd83eb444ed5d0ebd6f7169de5944549bda32d
Author: RiverRay <[email protected]>
Date:   Wed Jan 22 13:08:33 2025 +0800

    Update README_CN.md

commit b2b6fd81bedeb55043a13ec41ee6775df48ef5b3
Merge: 8111acff f22cfd7b
Author: RiverRay <[email protected]>
Date:   Mon Jan 20 10:44:46 2025 +0800

    Merge pull request #6075 from Kadxy/main

commit f22cfd7b33a81c8f245001ccd772c94a6162a54b
Author: Kadxy <[email protected]>
Date:   Mon Jan 20 10:10:52 2025 +0800

    Update chat.tsx

commit 8111acff34189ab980baca279c4fa811f63aac8b
Author: RiverRay <[email protected]>
Date:   Mon Jan 20 00:17:47 2025 +0800

    Update README.md

commit 4cad55379d8b32d6b46c2f6c7bd42a8f3dd17877
Merge: 93652db6 a3d3ce3f
Author: RiverRay <[email protected]>
Date:   Mon Jan 20 00:07:41 2025 +0800

    Merge pull request #5974 from ChatGPTNextWeb/feat-mcp

    Support MCP( WIP)

commit a3d3ce3f4cb95837811deb366459f40447f7af6d
Merge: 611e97e6 93652db6
Author: Kadxy <[email protected]>
Date:   Sun Jan 19 23:28:12 2025 +0800

    Merge branch 'main' into feat-mcp

commit 611e97e641d9d8b6c80e36da29fa21a2705f972d
Author: Kadxy <[email protected]>
Date:   Sun Jan 19 23:20:58 2025 +0800

    docs: update README.md

commit bfeea4ed4996c103d5ee36a908d6726e82472300
Author: Kadxy <[email protected]>
Date:   Sun Jan 19 01:02:01 2025 +0800

    fix: prevent MCP operations from blocking chat interface

commit bc71ae247bd1110658aef933eaf301b344181122
Author: Kadxy <[email protected]>
Date:   Sat Jan 18 21:19:01 2025 +0800

    feat: add ENABLE_MCP env var to toggle MCP feature globally and in Docker

commit 0112b54bc7b0d929b6f127daf00cfb0f2e05d1bc
Author: Kadxy <[email protected]>
Date:   Thu Jan 16 22:35:26 2025 +0800

    fix: missing en translation

commit 65810d918bb599716e35c8ea515a265da909cf2f
Author: Kadxy <[email protected]>
Date:   Thu Jan 16 21:30:15 2025 +0800

    feat: improve async operations and UI feedback

commit 4d535b1cd0c641d573a97e03fb5d9cb84a9f5ce5
Author: river <[email protected]>
Date:   Thu Jan 16 20:54:24 2025 +0800

    chore: enhance mcp prompt

commit 588d81e8f19047110a87196259df9fc2e8dbc0ce
Author: Kadxy <[email protected]>
Date:   Thu Jan 16 09:17:08 2025 +0800

    feat: remove unused files

commit d4f499ee41c8ab1c044fb690b980dc3d903d4e25
Author: Kadxy <[email protected]>
Date:   Thu Jan 16 09:11:53 2025 +0800

    feat: adjust form style

commit 4d63d73b2e8b7b382a4cc1f60fdd20cb8c5f953a
Author: Kadxy <[email protected]>
Date:   Thu Jan 16 09:00:57 2025 +0800

    feat: load MCP preset data from server

commit 07c63497dcbacee489d24db890281f84c2793e78
Author: Kadxy <[email protected]>
Date:   Thu Jan 16 08:52:54 2025 +0800

    feat: support stop/start MCP servers

commit e440ff56c89d11b29cdbb303eb8a9a71cddc2553
Author: Kadxy <[email protected]>
Date:   Wed Jan 15 18:47:05 2025 +0800

    fix: env not work

commit c89e4883b29142cfcb9254b7ff9815a5fe0b8d67
Author: river <[email protected]>
Date:   Wed Jan 15 17:31:18 2025 +0800

    chore: update icon

commit ac3d940de8d949e40a91d903d17901384d55e79c
Merge: a70e9a3c be59de56
Author: river <[email protected]>
Date:   Wed Jan 15 17:29:43 2025 +0800

    Merge branch 'feat-mcp' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web into feat-mcp

commit be59de56f0074c4fde7358465f844d09b48ab273
Author: Kadxy <[email protected]>
Date:   Wed Jan 15 17:24:04 2025 +0800

    feat: Display the number of clients instead of the number of available tools.

commit a70e9a3c01dccb887fc41c3d60f2c101d0b1cf2e
Author: river <[email protected]>
Date:   Wed Jan 15 17:23:10 2025 +0800

    chore:update mcp icon

commit 8aa9a500fdee762abe5fd8e0bba00065be1725f4
Author: Kadxy <[email protected]>
Date:   Wed Jan 15 16:52:54 2025 +0800

    feat: Optimize MCP configuration logic

commit 93652db688d2697abc7a6d4bdbe672fb8b509e33
Author: RiverRay <[email protected]>
Date:   Mon Jan 13 16:57:50 2025 +0800

    Update README.md

commit 8421c483e880d39405404ba1697a2169becee9f3
Author: RiverRay <[email protected]>
Date:   Sun Jan 12 12:56:13 2025 +0800

    Update README.md

commit 4ac27fdd4d98e6d339976b676b5be709973014cf
Merge: b6b2c501 840c151a
Author: Dogtiti <[email protected]>
Date:   Sat Jan 11 16:19:02 2025 +0800

    Merge pull request #6033 from lvguanjun/fix_fork_session

    fix: prevent message sync between forked sessions by generating unique IDs

commit b6b2c501fd58c8b533ff7890c00ce8eee887617d
Merge: 0af04e0f c56587c4
Author: Dogtiti <[email protected]>
Date:   Sat Jan 11 16:17:32 2025 +0800

    Merge pull request #6034 from dupl/main

    Correct the typos in user-manual-cn.md

commit ce13cf61a74f7b0682c230efed2742db91c7d1b7
Author: Kadxy <[email protected]>
Date:   Thu Jan 9 20:15:47 2025 +0800

    feat: ignore mcp_config.json

commit a3af563e894286654bf1e7cf1f66190d9c467a79
Author: Kadxy <[email protected]>
Date:   Thu Jan 9 20:13:16 2025 +0800

    feat: Reset mcp_config.json to empty

commit e95c94d7be72490668d8e022fd126cfe637b5f2a
Author: Kadxy <[email protected]>
Date:   Thu Jan 9 20:10:10 2025 +0800

    fix: inaccurate content

commit 125a71feade05ad5f5a75dc8f979c1efc946cdab
Author: Kadxy <[email protected]>
Date:   Thu Jan 9 20:07:24 2025 +0800

    fix: unnecessary initialization

commit b410ec399cefc78b7313ff387537edbe87ef4235
Author: Kadxy <[email protected]>
Date:   Thu Jan 9 20:02:27 2025 +0800

    feat: auto scroll to bottom when MCP response

commit 7d51bfd42e0f60a328abed353ab1ef717b6f3ba8
Author: Kadxy <[email protected]>
Date:   Thu Jan 9 19:51:01 2025 +0800

    feat: MCP market

commit 0c14ce6417821d512d04dec5a5755bf35deed51d
Author: Kadxy <[email protected]>
Date:   Thu Jan 9 13:41:17 2025 +0800

    fix: MCP execution content matching failed.

commit f2a2b40d2c07172db28cdd685fa8c9098c995acc
Author: Kadxy <[email protected]>
Date:   Thu Jan 9 10:20:56 2025 +0800

    feat: carry mcp primitives content as a system prompt

commit 77be190d763189915c520d431fc4aa889ca96c7e
Author: Kadxy <[email protected]>
Date:   Thu Jan 9 10:09:46 2025 +0800

    feat: carry mcp primitives content as a system prompt

commit c56587c438611e55251d930d038878e660145ad1
Author: dupl <[email protected]>
Date:   Sun Jan 5 20:34:18 2025 +0800

    Correct the typos in user-manual-cn.md

commit 840c151ab9ea7e384be37b774ea339264b5c0dc6
Author: lvguanjun <[email protected]>
Date:   Sun Jan 5 11:22:53 2025 +0800

    fix: prevent message sync between forked sessions by generating unique IDs

commit 0af04e0f2f5af2c39cdd771b2ebb496d9ca47f28
Merge: 63c5baaa d184eb64
Author: RiverRay <[email protected]>
Date:   Tue Dec 31 16:23:10 2024 +0800

    Merge pull request #5468 from DDMeaqua/feat-shortcutkey

    feat: #5422 快捷键清除上下文

commit d184eb64585562de7f75e1ff7d291eb242b2f076
Author: DDMeaqua <[email protected]>
Date:   Tue Dec 31 14:50:54 2024 +0800

    chore: cmd + shift+ backspace

commit c5d9b1131ec932e53cd0394c283e24549f6426cb
Author: DDMeaqua <[email protected]>
Date:   Tue Dec 31 14:38:58 2024 +0800

    fix: merge bug

commit e13408dd2480c1726d0333d8ede3a937187f7991
Merge: aba4baf3 63c5baaa
Author: DDMeaqua <[email protected]>
Date:   Tue Dec 31 14:30:09 2024 +0800

    Merge branch 'main' into feat-shortcutkey

commit aba4baf38403dd717ee04f5555ba81749d9ee6c8
Author: DDMeaqua <[email protected]>
Date:   Tue Dec 31 14:25:43 2024 +0800

    chore: update

commit 6d84f9d3ae62da0c5d1617645f961d9f9e1a1a27
Author: DDMeaqua <[email protected]>
Date:   Tue Dec 31 13:27:15 2024 +0800

    chore: update

commit 63c5baaa80878cb4c1a883ed658e8115b8006dce
Merge: defefba9 266e9efd
Author: Dogtiti <[email protected]>
Date:   Tue Dec 31 09:56:46 2024 +0800

    Merge pull request #6010 from code-october/fix-visionModels

    修复 VISION_MDOELS 在 docker 运行阶段不生效的问题

commit defefba925ef20b639d04cbab1ca3fdad3919eb6
Merge: d56566cd 90c531c2
Author: Dogtiti <[email protected]>
Date:   Mon Dec 30 19:27:20 2024 +0800

    Merge pull request #6016 from bestsanmao/add_deepseek

    fix issue #6009  add setting items for deepseek

commit 90c531c2249c1e2070e4f605d25a8e31c315ebdb
Author: suruiqiang <[email protected]>
Date:   Mon Dec 30 18:23:18 2024 +0800

    fix issue #6009  add setting items for deepseek

commit 266e9efd2e004664d73f0aa7f93a8684c0e5c55e
Author: code-october <[email protected]>
Date:   Mon Dec 30 09:13:12 2024 +0000

    rename the function

commit 57c88c0717bf21f29395642f32a306dc2388018d
Author: code-october <[email protected]>
Date:   Mon Dec 30 08:58:41 2024 +0000

    修复 VISION_MDOELS 在 docker 运行阶段不生效的问题

commit 5b5dea1c59605f26b382d780b5a558169d1a1021
Author: DDMeaqua <[email protected]>
Date:   Mon Dec 30 12:11:50 2024 +0800

    chore: 更换快捷键

commit d56566cd73b1936a66f3ad2e8a30dd351aa96464
Merge: f9e9129d b5d104c9
Author: Dogtiti <[email protected]>
Date:   Mon Dec 30 09:42:22 2024 +0800

    Merge pull request #6001 from bestsanmao/add_deepseek

    docs: add DEEPSEEK_API_KEY and DEEPSEEK_URL in README

commit b5d104c908fb9442ddadb9bd4e544b7fa974c9fd
Merge: 2a8a1839 f9e9129d
Author: suruiqiang <[email protected]>
Date:   Mon Dec 30 09:04:40 2024 +0800

    Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web into add_deepseek

commit f9e9129d527a644d8baad97e12ece04601035b2c
Author: RiverRay <[email protected]>
Date:   Sun Dec 29 19:57:27 2024 +0800

    Update README.md

commit 2a8a18391ebc563a9a552dfdac8a0a66d833e0d7
Author: suruiqiang <[email protected]>
Date:   Sun Dec 29 15:31:50 2024 +0800

    docs: add DEEPSEEK_API_KEY and DEEPSEEK_URL in README

commit e1cb8e36fab99faa1e60fecc6d7fd57607177cd2
Merge: c0062ff2 67338ff9
Author: Dogtiti <[email protected]>
Date:   Sun Dec 29 12:35:21 2024 +0800

    Merge pull request #5989 from bestsanmao/add_deepseek

    since #5984, add DeepSeek as a new ModelProvider (with deepseek-chat&deepseek-coder models), so that user can use openai and deepseek at same time with different api url & key

commit b948d6bf86ba4410c854a3c73df275c42be89baa
Author: suruiqiang <[email protected]>
Date:   Sun Dec 29 11:24:57 2024 +0800

    bug fix

commit fe67f79050c7f4b8971f9b9aabc22c5fd23bac07
Author: Kadxy <[email protected]>
Date:   Sun Dec 29 09:24:52 2024 +0800

    feat: MCP message type

commit 67338ff9b73eebe5f8fcc317f0f3d93d32bff836
Author: suruiqiang <[email protected]>
Date:   Sun Dec 29 08:58:45 2024 +0800

    add KnowledgeCutOffDate for deepseek

commit 7380c8a2c10bfd314f5a1afd1e5b1b401733e485
Merge: 081daf93 c0062ff2
Author: suruiqiang <[email protected]>
Date:   Sun Dec 29 08:43:25 2024 +0800

    Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web into add_deepseek

commit e1ba8f1b0f122a73194b2f3716fdb78173647e05
Author: Kadxy <[email protected]>
Date:   Sun Dec 29 08:29:02 2024 +0800

    feat: Send MCP response as a user

commit c0062ff2802a6d921895517aa4ab17b1c897fe72
Merge: f8b10ad8 39e593da
Author: Dogtiti <[email protected]>
Date:   Sun Dec 29 00:22:13 2024 +0800

    Merge pull request #5998 from dupl/main

    Use regular expressions to make the code more concise.

commit 39e593da48cf63df840e9133e9ee4ad5f8dbc986
Author: dupl <[email protected]>
Date:   Sat Dec 28 23:49:28 2024 +0800

    Use regular expressions to make the code more concise.

commit f8b10ad8b173927861c6d1df12e07470465c9a1e
Merge: 5f96804f 8a22c9d6
Author: Dogtiti <[email protected]>
Date:   Sat Dec 28 23:34:44 2024 +0800

    Merge pull request #5997 from ChatGPTNextWeb/feature/glm-4v

    feature: support glm-4v

commit 8a22c9d6dbe2d1e041c9f9daed5768a8bdd0f7a9
Author: Dogtiti <[email protected]>
Date:   Sat Dec 28 23:29:39 2024 +0800

    feature: support glm-4v

commit 5f96804f3b1155fc870547a79588c0856283b66a
Merge: 13430ea3 93c5320b
Author: RiverRay <[email protected]>
Date:   Sat Dec 28 22:05:37 2024 +0800

    Merge pull request #5920 from fishshi/i18n

    Use i18n for DISCOVERY

commit 13430ea3e261290881d1fbf4c65b52624cba9d0b
Merge: 9df24e56 87b5e3bf
Author: RiverRay <[email protected]>
Date:   Sat Dec 28 22:02:02 2024 +0800

    Merge pull request #5965 from zmhuanf/temp

    Fix issue #5964: Prevents character loss in gemini-2.0-flash-thinking-exp-1219 responses

commit 664879b9df8c431664b06346962cff0319a3e85e
Author: Kadxy <[email protected]>
Date:   Sat Dec 28 21:06:26 2024 +0800

    feat: Create all MCP Servers at startup

commit 9df24e568b5ec280aa05cb8da7dd29c64f06c0b4
Merge: e467ce02 bc322be4
Author: Dogtiti <[email protected]>
Date:   Sat Dec 28 20:25:25 2024 +0800

    Merge pull request #5996 from ChatGPTNextWeb/feature/cogview

    Feature/cogview

commit bc322be448136a0dcb3f8adf93faae698b28b5d3
Author: Dogtiti <[email protected]>
Date:   Fri Dec 27 22:35:40 2024 +0800

    fix: type error

commit a867adaf046395b7a6ee88b402bc1c3c477696f2
Author: Dogtiti <[email protected]>
Date:   Fri Dec 27 21:57:23 2024 +0800

    fix: size

commit 0cb186846a03b95dfc4dd0d3b1f25dac48ac1026
Author: Dogtiti <[email protected]>
Date:   Fri Dec 27 21:52:22 2024 +0800

    feature: support glm Cogview

commit e467ce028d61f717b86bebf71b9ded1ac41cb3d5
Merge: d91af7f9 cdfe907f
Author: Dogtiti <[email protected]>
Date:   Sat Dec 28 17:55:29 2024 +0800

    Merge pull request #5994 from ConnectAI-E/fix/failed-test

    fix: failed unit test

commit cdfe907fb506c467324a5a53e4b33f883a30eba3
Author: Dogtiti <[email protected]>
Date:   Sat Dec 28 17:54:21 2024 +0800

    fix: failed unit test

commit d91af7f9831a44a4bcafc9aef8b38dfef5739880
Merge: 0c3d4462 cc5e16b0
Author: Dogtiti <[email protected]>
Date:   Sat Dec 28 14:47:35 2024 +0800

    Merge pull request #5883 from code-october/fix/model-leak

    fix model leak issue

commit c3108ad333419ecb0d16a031d4f4603f0f781832
Author: Kadxy <[email protected]>
Date:   Sat Dec 28 14:31:43 2024 +0800

    feat: simple MCP example

commit 081daf937e4c18eb787662ca1a0fad561f54b9c6
Author: suruiqiang <[email protected]>
Date:   Fri Dec 27 16:46:44 2024 +0800

    since #5984, add DeepSeek as a new ModelProvider (with deepseek-chat&deepseek-corder models), so that user can use openai and deepseek at same time with different api url&key

commit 0c3d4462caa2abe5187856a2619b871ce8c33488
Merge: 1d156667 3c859fc2
Author: RiverRay <[email protected]>
Date:   Mon Dec 23 22:47:59 2024 +0800

    Merge pull request #5976 from ChatGPTNextWeb/Leizhenpeng-patch-1

    Update README.md

commit 3c859fc29fc11ac9c229ed024d2d25366b8d2d99
Author: RiverRay <[email protected]>
Date:   Mon Dec 23 22:47:16 2024 +0800

    Update README.md

commit e1c7c54dfaf82c37450d0ed3a124f8598bc0249b
Author: river <[email protected]>
Date:   Mon Dec 23 22:32:36 2024 +0800

    chore: change md

commit 87b5e3bf6252be247b32385a19d9897bede5cdf0
Author: zmhuanf <[email protected]>
Date:   Sun Dec 22 15:44:47 2024 +0800

    修复bug;

commit 1d15666713c27f89912cf913387176a76fc00f66
Merge: acc2e97a a127ae1f
Author: Dogtiti <[email protected]>
Date:   Sun Dec 22 10:37:57 2024 +0800

    Merge pull request #5919 from Yiming3/feature/flexible-visual-model

    feat: runtime configuration of vision-capable models

commit a127ae1fb45d641b9f138057e56a10ece96b2964
Author: Yiming Zhang <[email protected]>
Date:   Sat Dec 21 13:12:41 2024 -0500

    docs: add VISION_MODELS section to README files

commit ea1329f73e516546dab7193425e1e7dfdd232eb6
Author: Yiming Zhang <[email protected]>
Date:   Sat Dec 21 04:07:58 2024 -0500

    fix: add optional chaining to prevent errors when accessing visionModels

commit 149d732cb78287c51edcd67d1fd5b16a5f334813
Merge: 210b29bf acc2e97a
Author: Yiming Zhang <[email protected]>
Date:   Sat Dec 21 03:53:05 2024 -0500

    Merge remote-tracking branch 'upstream/main' into feature/flexible-visual-model

commit 210b29bfbecaebc53c4f37ed23c5df28d28d41fb
Author: Yiming Zhang <[email protected]>
Date:   Sat Dec 21 03:51:54 2024 -0500

    refactor: remove NEXT_PUBLIC_ prefix from VISION_MODELS env var

commit acc2e97aab7437030db157605796482686a96f90
Merge: eceec092 93ac0e50
Author: Dogtiti <[email protected]>
Date:   Sat Dec 21 16:30:09 2024 +0800

    Merge pull request #5959 from dupl/gemini

    add gemini-exp-1206, gemini-2.0-flash-thinking-exp-1219

commit 93ac0e501737f8e01d046a367d0aeb0055c15633
Author: dupl <[email protected]>
Date:   Sat Dec 21 15:26:33 2024 +0800

    Reorganized the Gemini model

commit ed8c3580c8fce9c12c42e2a8ac086ea2f8887953
Author: Yiming Zhang <[email protected]>
Date:   Fri Dec 20 19:07:00 2024 -0500

    test: add unit tests for isVisionModel utility function

commit 0a056a7c5c0be993321174706d8b679e7ffde038
Author: dupl <[email protected]>
Date:   Sat Dec 21 08:00:37 2024 +0800

    add gemini-exp-1206, gemini-2.0-flash-thinking-exp-1219

commit 74c4711cdd2c38c8136490fb27eb878cc1c8b001
Merge: a433d160 eceec092
Author: Yiming Zhang <[email protected]>
Date:   Fri Dec 20 18:34:07 2024 -0500

    Merge remote-tracking branch 'upstream/main' into feature/flexible-visual-model

commit eceec092cfc57f4024a8aab3869e39f6eebfef30
Merge: 42743410 46a0b100
Author: Dogtiti <[email protected]>
Date:   Sat Dec 21 00:43:02 2024 +0800

    Merge pull request #5932 from fengzai6/update-google-models

    Update google models to add gemini-2.0

commit 42743410a8ce5028cc359863c97baddc16ad8d64
Merge: 0f04756d acdded81
Author: Dogtiti <[email protected]>
Date:   Sat Dec 21 00:41:45 2024 +0800

    Merge pull request #5940 from ChatGPTNextWeb/dependabot/npm_and_yarn/testing-library/react-16.1.0

    chore(deps-dev): bump @testing-library/react from 16.0.1 to 16.1.0

commit 0f04756d4cda9b2bfd0308c72652268b3ec8b5b3
Merge: 83cea3a9 e939ce5a
Author: Dogtiti <[email protected]>
Date:   Sat Dec 21 00:40:45 2024 +0800

    Merge pull request #5936 from InitialXKO/main

    面具“以文搜图”改成“AI文生图”,微调提示让图片生成更稳定无水印

commit acdded8161860def9fe0f3806798bcdc57754644
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Dec 16 10:57:34 2024 +0000

    chore(deps-dev): bump @testing-library/react from 16.0.1 to 16.1.0

    Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 16.0.1 to 16.1.0.
    - [Release notes](https://github.com/testing-library/react-testing-library/releases)
    - [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/testing-library/react-testing-library/compare/v16.0.1...v16.1.0)

    ---
    updated-dependencies:
    - dependency-name: "@testing-library/react"
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

commit e939ce5a027150d2481508691e1c4f818a4f9130
Author: InitialXKO <[email protected]>
Date:   Fri Dec 13 22:29:14 2024 +0800

    面具“以文搜图”改成“AI文生图”,微调提示让图片生成更稳定无水印

commit 46a0b100f73058d651b884341b43e126e2c04a00
Author: Nacho.L <[email protected]>
Date:   Fri Dec 13 08:29:43 2024 +0800

    Update versionKeywords

commit e27e8fb0e16ee61865d11606682f2c4cbd075e73
Author: Nacho.L <[email protected]>
Date:   Fri Dec 13 07:22:16 2024 +0800

    Update google models

commit 93c5320bf29a8da64e12d3870ea932631ad51b2a
Author: fishshi <[email protected]>
Date:   Tue Dec 10 15:56:04 2024 +0800

    Use i18n for DISCOVERY

commit a433d1606cc9f24cec7f7cc0a947e416373a5d7b
Author: Yiming Zhang <[email protected]>
Date:   Tue Dec 10 00:22:45 2024 -0500

    feat: use regex patterns for vision models and allow adding capabilities to models through env var NEXT_PUBLIC_VISION_MODELS.

commit cc5e16b0454481fab48b1115eda9b8fb11ce0054
Author: code-october <[email protected]>
Date:   Sat Nov 30 07:30:52 2024 +0000

    update unit test

commit 54f6feb2d74b9ac81fa5f826f24f73929c7cb238
Author: code-october <[email protected]>
Date:   Sat Nov 30 07:28:38 2024 +0000

    update unit test

commit e1ac0538b8143f93074c1c248a5739358b3ddfd1
Author: code-october <[email protected]>
Date:   Sat Nov 30 07:22:24 2024 +0000

    add unit test

commit 1a678cb4d832fe47f5d04e614bb267907bbf2677
Author: code-october <[email protected]>
Date:   Fri Nov 29 15:47:28 2024 +0000

    fix model leak issue

commit 83cea3a90d115f9564d96f6a6af400f467f2d3b4
Merge: 2623a927 759a09a7
Author: Dogtiti <[email protected]>
Date:   Thu Nov 28 12:02:42 2024 +0800

    Merge pull request #5879 from frostime/textline-custom-model

    🎨 style(setting): Place custom-model's input a separated row.

commit 759a09a76c8c6cd97cd4546da022f38f426618f2
Author: frostime <[email protected]>
Date:   Wed Nov 27 13:11:18 2024 +0800

    🎨 style(setting): Place custom-model's input a seperated row.

commit 2623a9276388668d65f34e1ad2206bec55acde79
Merge: 3932c594 ef24d3e6
Author: Dogtiti <[email protected]>
Date:   Mon Nov 25 12:31:36 2024 +0800

    Merge pull request #5850 from code-october/fix-o1

    Fix o1

commit 3932c594c71a4d52968c5bd19ab75cba2197ea76
Merge: a2adfbbd b7acb890
Author: Dogtiti <[email protected]>
Date:   Fri Nov 22 20:59:30 2024 +0800

    Merge pull request #5861 from code-october/update-model

    update new model for gpt-4o and gemini-exp

commit b7acb890969fe5af9135bb49533fad610ac52e69
Author: code-october <[email protected]>
Date:   Fri Nov 22 09:48:50 2024 +0000

    update new model for gpt-4o and gemini-exp

commit ef24d3e63360eea8868334f884d83f747cfd8f73
Author: code-october <[email protected]>
Date:   Thu Nov 21 03:46:10 2024 +0000

    use stream when request o1

commit 23350c842b1b102ebdbb17ccbb2b5cfa7b25b893
Author: code-october <[email protected]>
Date:   Thu Nov 21 03:45:07 2024 +0000

    fix o1 in disableGPT4

commit a2adfbbd3242cb38c685c48a1a8d2cba2c2b28cd
Merge: f22cec1e 19facc7c
Author: Dogtiti <[email protected]>
Date:   Sat Nov 16 15:24:46 2024 +0800

    Merge pull request #5821 from Sherlocksuper/scroll

    feat: support more user-friendly scrolling

commit f22cec1eb4a92fc9c388595ba3ca23d2820ba56e
Merge: b08ce563 e5621654
Author: Lloyd Zhou <[email protected]>
Date:   Fri Nov 15 16:03:27 2024 +0800

    Merge pull request #5827 from ConnectAI-E/fix/markdown-embed-codeblock

    fix: 代码块嵌入小代码块时渲染错误

commit e56216549efe58c1b734f5094eb77bfaa6654c69
Author: opchips <[email protected]>
Date:   Fri Nov 15 11:56:26 2024 +0800

    fix: 代码块嵌入小代码块时渲染错误

commit 19facc7c85a0e509b5d4ca1eaa98782f29477c9a
Author: Sherlock <[email protected]>
Date:   Thu Nov 14 21:31:45 2024 +0800

    feat: support mort user-friendly scrolling

commit b08ce5630c5c24491459cca2e3bcc9c8b6a68114
Merge: a392daab b41c012d
Author: Lloyd Zhou <[email protected]>
Date:   Wed Nov 13 15:17:44 2024 +0800

    Merge pull request #5819 from ConnectAI-E/fix-gemini-summary

    Fix gemini summary

commit b41c012d27d5495bec12f6aa6f9537ebb6873083
Author: DDMeaqua <[email protected]>
Date:   Wed Nov 13 15:12:46 2024 +0800

    chore: shouldStream

commit a392daab716d66a7a9fb95e30e2574bf87716bb4
Merge: 819d249a 9a86c42c
Author: Lloyd Zhou <[email protected]>
Date:   Wed Nov 13 14:58:33 2024 +0800

    Merge pull request #5816 from ConnectAI-E/feature/artifacts-svg

    artifacts support svg

commit 0628ddfc6f36479650d50281e3fa0ba1a847f777
Author: DDMeaqua <[email protected]>
Date:   Wed Nov 13 14:27:41 2024 +0800

    chore: update

commit 7eda14f13882be635c9e6e5b8077617df8c5339b
Author: DDMeaqua <[email protected]>
Date:   Wed Nov 13 14:24:44 2024 +0800

    fix: [#5308] gemini对话总结

commit 9a86c42c95be5b2bb85f44c0bdeb7714dc526a49
Author: opchips <[email protected]>
Date:   Tue Nov 12 16:33:55 2024 +0800

    update

commit 819d249a099ba84017afc5b5c20ae8309889b060
Merge: 7cf89b53 8d66fedb
Author: Lloyd Zhou <[email protected]>
Date:   Tue Nov 12 15:04:11 2024 +0800

    Merge pull request #5815 from LovelyGuYiMeng/main

    更新视觉模型匹配关键词

commit 8d66fedb1f5093d6e29ac06a839316edb535512d
Author: LovelyGuYiMeng <[email protected]>
Date:   Tue Nov 12 14:28:11 2024 +0800

    Update visionKeywords

commit 7cf89b53ce129ec3c51181571b34b658894673b2
Merge: 459c373f 1d14a991
Author: Lloyd Zhou <[email protected]>
Date:   Tue Nov 12 13:49:51 2024 +0800

    Merge pull request #5812 from ConnectAI-E/fix/rerender-chat

    fix: use current session id to trigger rerender

commit 459c373f130d04cec80761a81cbb651afc485135
Merge: 38fa3056 05ef5adf
Author: Dogtiti <[email protected]>
Date:   Mon Nov 11 20:59:56 2024 +0800

    Merge pull request #5807 from ChatGPTNextWeb/dependabot/npm_and_yarn/testing-library/jest-dom-6.6.3

    chore(deps-dev): bump @testing-library/jest-dom from 6.6.2 to 6.6.3

commit 1d14a991eedb17a492d6e840de71567c8a6884a7
Author: Dogtiti <[email protected]>
Date:   Mon Nov 11 20:30:59 2024 +0800

    fix: use current session id to trigger rerender

commit 05ef5adfa72d2a519a07c36aca4e6c1a965da7d2
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Nov 11 10:53:00 2024 +0000

    chore(deps-dev): bump @testing-library/jest-dom from 6.6.2 to 6.6.3

    Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 6.6.2 to 6.6.3.
    - [Release notes](https://github.com/testing-library/jest-dom/releases)
    - [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/testing-library/jest-dom/compare/v6.6.2...v6.6.3)

    ---
    updated-dependencies:
    - dependency-name: "@testing-library/jest-dom"
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

commit 38fa3056df5fd9db915a9d4d1c5e11477de22ff6
Author: lloydzhou <[email protected]>
Date:   Mon Nov 11 13:26:08 2024 +0800

    update version

commit 289aeec8af234f2ff6092722f2ea955c5768f342
Merge: f8f69541 7d71da93
Author: Lloyd Zhou <[email protected]>
Date:   Mon Nov 11 13:19:26 2024 +0800

    Merge pull request #5786 from ConnectAI-E/feature/realtime-chat

    Feature/realtime chat

commit 7d71da938fab927758f6c80921c4eee371deec70
Author: lloydzhou <[email protected]>
Date:   Mon Nov 11 13:15:09 2024 +0800

    remove close-24 svg

commit f8f6954115a5fd0caad88470a530ff7c2378c43a
Merge: 6e03f328 64aa760e
Author: Lloyd Zhou <[email protected]>
Date:   Mon Nov 11 13:13:09 2024 +0800

    Merge pull request #5779 from ConnectAI-E/feature/model/claude35haiku

    add claude35haiku & not support vision

commit 6e03f3287123bb0bffc2aafd0f0a3c72566540a2
Merge: 108069a0 18a65718
Author: Lloyd Zhou <[email protected]>
Date:   Mon Nov 11 13:10:00 2024 +0800

    Merge pull request #5795 from JingSyue/main

    fix: built-in plugin dalle3 error #5787

commit 18a657188339ac96905f0eaadd0583fdd6001f65
Author: JingSyue <[email protected]>
Date:   Mon Nov 11 12:59:29 2024 +0800

    Update proxy.ts

    Update proxy.ts

commit 14f444e1f0ca4253b65534140f9239d0504e1af6
Author: Dogtiti <[email protected]>
Date:   Mon Nov 11 11:47:41 2024 +0800

    doc: realtime chat

commit 2b0f2e5f9d064bc8107414b0c2e7efe61c03cdef
Author: JingSyue <[email protected]>
Date:   Sun Nov 10 10:28:25 2024 +0800

    fix: built-in plugin dalle3 error #5787

commit 4629b39c297f51cf1a7e1685c62043578f653d21
Author: Dogtiti <[email protected]>
Date:   Sat Nov 9 16:22:01 2024 +0800

    chore: comment context history

commit d33e772fa592c24e4adc03f127c887c9e4727913
Author: Dogtiti <[email protected]>
Date:   Fri Nov 8 22:39:17 2024 +0800

    feat: voice print

commit 89136fba32dbf731e4aaed03508684cfeb54614b
Author: Dogtiti <[email protected]>
Date:   Fri Nov 8 22:18:39 2024 +0800

    feat: voice print

commit 8b4ca133fda68ed7034ee5bbae8d622d66bf81f9
Author: Dogtiti <[email protected]>
Date:   Fri Nov 8 22:02:31 2024 +0800

    feat: voice print

commit a4c9eaf6cd5f889fc77877885a52d45866579841
Author: lloydzhou <[email protected]>
Date:   Fri Nov 8 13:43:13 2024 +0800

    do not save empty audio file

commit 50e63109a35b6aff7056c129e30d745d74835226
Author: lloydzhou <[email protected]>
Date:   Fri Nov 8 13:21:40 2024 +0800

    merge code and get analyser data

commit 48a1e8a58469eceb92dfa41559638ad2583fca70
Author: Dogtiti <[email protected]>
Date:   Thu Nov 7 21:32:47 2024 +0800

    chore: i18n

commit e44ebe3f0eda9ab6f08dc6a58601e333dd46101b
Author: Dogtiti <[email protected]>
Date:   Thu Nov 7 21:28:23 2024 +0800

    feat: realtime config

commit 108069a0c6d1689c089ed2257a8e085c754a25b9
Merge: fbb9385f d5bda290
Author: Lloyd Zhou <[email protected]>
Date:   Thu Nov 7 20:06:30 2024 +0800

    Merge pull request #5788 from ConnectAI-E/fix-o1-maxtokens

    chore: o1模型使用max_completion_tokens

commit d5bda2904dcb7279d4addff8bbc93cb206fdc7d6
Author: DDMeaqua <[email protected]>
Date:   Thu Nov 7 19:45:27 2024 +0800

    chore: o1模型使用max_completion_tokens

commit 283caba8ce0e874e1876e6ef83a8d380e83f985f
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 18:57:57 2024 +0800

    stop streaming play after get input audio.

commit b78e5db81759ada7bb2813ae17d2d94bfae47d68
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 17:55:51 2024 +0800

    add temperature config

commit 46c469b2d7b95d21c8dc2c4c239c0646f3b43665
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 17:47:55 2024 +0800

    add voice config

commit c00ebbea4f774e15358c0a9410f807177931cff0
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 17:40:03 2024 +0800

    update

commit c526ff80b50ae2e284230093f0c51dc415b5cb46
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 17:23:20 2024 +0800

    update

commit 0037b0c94414c10b78ec2a152b36adc1d35bda2f
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 17:03:04 2024 +0800

    ts error

commit 6f81bb3b8a18f370cf3225c3c26fcaf7522e1317
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 16:56:15 2024 +0800

    add context after connected

commit 7bdc45ed3eb62833fee131ce93165823c1e4459f
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 16:41:24 2024 +0800

    connect realtime model when open panel

commit 88cd3ac122cfe0a93f3c87e441d9e1e59c8bfb33
Author: Dogtiti <[email protected]>
Date:   Thu Nov 7 12:16:11 2024 +0800

    fix: ts error

commit 4988d2ee26f5cd65b128dae8924942c54a9da3ee
Author: Dogtiti <[email protected]>
Date:   Thu Nov 7 11:56:58 2024 +0800

    fix: ts error

commit 8deb7a92ee7a9f15f749a93216abc789ac502718
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 11:53:01 2024 +0800

    hotfix for update target session

commit db060d732abeab3724f61eeae9ed6f5b4c93c9be
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 11:45:38 2024 +0800

    upload save record wav file

commit 522627820a1aa641ee5746930626e8a4153cd611
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 09:36:22 2024 +0800

    upload save wav file logic

commit cf46d5ad63bc13dd4e7f938689fdb3c65a09e929
Author: lloydzhou <[email protected]>
Date:   Thu Nov 7 01:12:08 2024 +0800

    upload response audio, and update audio_url to session message

commit a4941521d0973943bbd0abba86dc7295b444f2b5
Author: Dogtiti <[email protected]>
Date:   Wed Nov 6 22:30:02 2024 +0800

    feat: audio to message

commit f6e1f8398b261b8d0a65c971e62ac0fa5178e743
Author: Dogtiti <[email protected]>
Date:   Wed Nov 6 22:07:33 2024 +0800

    wip

commit d544eead3818f69413de20c25c5f3578439b7a4d
Author: Dogtiti <[email protected]>
Date:   Wed Nov 6 21:14:45 2024 +0800

    feat: realtime chat ui

commit fbb9385f23246e86147df4c4efb29b2efad893b0
Merge: 6ded4e96 18144c3d
Author: Lloyd Zhou <[email protected]>
Date:   Wed Nov 6 20:33:51 2024 +0800

    Merge pull request #5782 from ConnectAI-E/style/classname

    style: improve classname by clsx

commit 18144c3d9c91e8047b5d56ace69fb9e9829f7a78
Author: Dogtiti <[email protected]>
Date:   Wed Nov 6 20:16:38 2024 +0800

    chore: clsx

commit 64aa760e58f31ab45ce720b988c859dd53c491ca
Author: opchips <[email protected]>
Date:   Wed Nov 6 19:18:05 2024 +0800

    update claude rank

commit e0bbb8bb68429d160c50af512eaa5181b50dc2c3
Author: Dogtiti <[email protected]>
Date:   Wed Nov 6 16:58:26 2024 +0800

    style: improve classname by clsx

commit 6667ee1c7fe655cd24bd56ed4e8611bfca5978cd
Merge: 3086a2fa 6ded4e96
Author: opchips <[email protected]>
Date:   Wed Nov 6 15:08:18 2024 +0800

    merge main

commit 6ded4e96e76fd4a9896d49a729520faabb47d112
Merge: f4c9410c 85cdcab8
Author: Lloyd Zhou <[email protected]>
Date:   Wed Nov 6 15:04:46 2024 +0800

    Merge pull request #5778 from ConnectAI-E/fix/5436

    fix: botMessage reply date

commit 85cdcab850cadbbd346d38b34603e3eb00e3e715
Author: Dogtiti <[email protected]>
Date:   Wed Nov 6 14:53:08 2024 +0800

    fix: botMessage reply date

commit f4c9410c29ac5b8d1979566c269ced96b74b2f57
Merge: f526d6f5 adf7d820
Author: Lloyd Zhou <[email protected]>
Date:   Wed Nov 6 14:02:20 2024 +0800

    Merge pull request #5776 from ConnectAI-E/feat-glm

    fix: glm chatpath

commit adf7d8200b63ba9e389c3df2b801b82a272a85bf
Author: DDMeaqua <[email protected]>
Date:   Wed Nov 6 13:55:57 2024 +0800

    fix: glm chatpath

commit 3086a2fa77d2815af05236bae4a13a4da387730b
Author: opchips <[email protected]>
Date:   Wed Nov 6 12:56:24 2024 +0800

    add claude35haiku not vision

commit f526d6f56094a5dc3e24b6a608681b2b0842f1d3
Merge: f3603e59 106461a1
Author: Lloyd Zhou <[email protected]>
Date:   Wed Nov 6 11:16:33 2024 +0800

    Merge pull request #5774 from ConnectAI-E/feature/update-target-session

    fix: updateCurrentSession => updateTargetSession

commit 106461a1e72b3c62395903945fac27fe165e9e4b
Merge: c4e19dbc f3603e59
Author: Dogtiti <[email protected]>
Date:   Wed Nov 6 11:08:41 2024 +0800

    Merge branch 'main' of https://github.com/ConnectAI-E/ChatGPT-Next-Web into feature/update-target-session

commit c4e19dbc59e59b71c81cf33600f7a2be235b0ccc
Author: Dogtiti <[email protected]>
Date:   Wed Nov 6 11:06:18 2024 +0800

    fix: updateCurrentSession => updateTargetSession

commit f3603e59faa182313a408f58012b0c83eb2b8956
Merge: 00d6cb27 8e2484fc
Author: Dogtiti <[email protected]>
Date:   Wed Nov 6 10:49:28 2024 +0800

    Merge pull request #5769 from ryanhex53/fix-model-multi@

    Custom model names can include the `@` symbol by itself.

commit 8e2484fcdf476a1248ae91541d6d491e5881b49b
Author: ryanhex53 <[email protected]>
Date:   Tue Nov 5 13:52:54 2024 +0000

    Refactor: Replace all provider split occurrences with getModelProvider utility method

commit 00d6cb27f719caffd24518db3dd656b7380a9062
Author: lloydzhou <[email protected]>
Date:   Tue Nov 5 17:42:55 2024 +0800

    update version

commit b844045d231658b9e40fa0582936c6746e7a7ef4
Author: ryanhex53 <[email protected]>
Date:   Tue Nov 5 07:44:12 2024 +0000

    Custom model names can include the `@` symbol by itself.

    To specify the model's provider, append it after the model name using `@` as before.

    This format supports cases like `google vertex ai` with a model name like `claude-3-5-sonnet@20240620`.

    For instance, `claude-3-5-sonnet@20240620@vertex-ai` will be split by `split(/@(?!.*@)/)` into:

    `[ 'claude-3-5-sonnet@20240620', 'vertex-ai' ]`, where the former is the model name and the latter is the custom provider.

commit e49fe976d9bd00106c163766aca915b291cb4956
Merge: 14f75196 e49466fa
Author: Lloyd Zhou <[email protected]>
Date:   Tue Nov 5 15:07:52 2024 +0800

    Merge pull request #5765 from ConnectAI-E/feature/onfinish

    feat: update real 'currentSession'

commit 14f751965f7a55bb9896f1a02c066591e8b22057
Merge: 820ab54e 0ec42338
Author: Dogtiti <[email protected]>
Date:   Tue Nov 5 11:07:52 2024 +0800

    Merge pull request #5767 from ConnectAI-E/feat-glm

    chore: update readme

commit 0ec423389fa08e4e4b046db5ad147194622b6218
Author: DDMeaqua <[email protected]>
Date:   Tue Nov 5 11:06:20 2024 +0800

    chore: update readme

commit 820ab54e2d8c0ce09c0b88d479b364f998b8d244
Merge: 0dc4071c a6c1eb27
Author: Dogtiti <[email protected]>
Date:   Tue Nov 5 10:54:52 2024 +0800

    Merge pull request #5766 from ConnectAI-E/feature/add-claude-haiku3.5

    Feature/add claude haiku3.5

commit a6c1eb27a82f4f18b043a0c382d5f694f8bd63aa
Merge: 801dc412 0dc4071c
Author: lloydzhou <[email protected]>
Date:   Tue Nov 5 10:23:15 2024 +0800

    add claude 3.5 haiku

commit 0dc4071ccce53fed990598da494316a6b199a3ee
Merge: aef535f1 4d394971
Author: Lloyd Zhou <[email protected]>
Date:   Tue Nov 5 01:10:06 2024 +0800

    Merge pull request #5464 from endless-learner/main

    Added 1-click deployment link for Alibaba Cloud.

commit 4d3949718a979ff7db1c10d30b7ab66793c95892
Author: Lloyd Zhou <[email protected]>
Date:   Tue Nov 5 01:09:27 2024 +0800

    merge main

commit aef535f1a7af3196a90cfc7f1887cfb432ea3d06
Merge: 686a80e7 fbb7a1e8
Author: Dogtiti <[email protected]>
Date:   Mon Nov 4 21:41:11 2024 +0800

    Merge pull request #5753 from ChatGPTNextWeb/feat-bt-doc

    Feat bt doc

commit 686a80e727f13bd828d37bb865742f801611d1e3
Merge: 5733e3c5 4b933708
Author: Dogtiti <[email protected]>
Date:   Mon Nov 4 21:37:34 2024 +0800

    Merge pull request #5764 from ChatGPTNextWeb/dependabot/npm_and_yarn/testing-library/react-16.0.1

    chore(deps-dev): bump @testing-library/react from 16.0.0 to 16.0.1

commit e49466fa054c702898780967812abe2dabd4ba6b
Author: Dogtiti <[email protected]>
Date:   Mon Nov 4 21:25:56 2024 +0800

    feat: update real 'currentSession'

commit 4b93370814b41e256de7cddc6264705883265d56
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Nov 4 10:24:30 2024 +0000

    chore(deps-dev): bump @testing-library/react from 16.0.0 to 16.0.1

    Bumps [@testing-library/react](https://github.com/testing-library/react-testing-library) from 16.0.0 to 16.0.1.
    - [Release notes](https://github.com/testing-library/react-testing-library/releases)
    - [Changelog](https://github.com/testing-library/react-testing-library/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/testing-library/react-testing-library/compare/v16.0.0...v16.0.1)

    ---
    updated-dependencies:
    - dependency-name: "@testing-library/react"
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

commit 5733e3c588f7467e20cc7782b2327f149c7663e8
Merge: d66bfc63 44fc5b5c
Author: Dogtiti <[email protected]>
Date:   Mon Nov 4 17:16:44 2024 +0800

    Merge pull request #5759 from ConnectAI-E/feature/onfinish

    Feature/onfinish

commit 44fc5b5cbf44b7a362a916fbc3b1c3a34cc8e7cb
Author: Dogtiti <[email protected]>
Date:   Mon Nov 4 17:00:45 2024 +0800

    fix: onfinish responseRes

commit 2d3f7c922f5a3e52da30f45b67a74f0df908e147
Author: Dogtiti <[email protected]>
Date:   Wed Oct 16 15:17:08 2024 +0800

    fix: vision model dalle3

commit fe8cca3730ba261548dfc06ea20b6a0824a7b5da
Merge: adf97c6d d66bfc63
Author: GH Action - Upstream Sync <[email protected]>
Date:   Sat Nov 2 01:12:09 2024 +0000

    Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web

commit fbb7a1e853334a9de54034aa41a18119e4e86028
Author: weige <[email protected]>
Date:   Fri Nov 1 18:20:16 2024 +0800

    fix

commit fb2c15567dc218edc1ce4f6bfac746a25607fd9d
Author: weige <[email protected]>
Date:   Fri Nov 1 17:45:50 2024 +0800

    fix

commit c2c52a1f605f2eeeac1865a7342968a7cfc36cf6
Author: weige <[email protected]>
Date:   Fri Nov 1 17:35:34 2024 +0800

    fix

commit 106ddc17cd3267201d4c620c50bfdce641e04ff0
Author: weige <[email protected]>
Date:   Fri Nov 1 17:35:09 2024 +0800

    fix

commit 17d5209738a114db34484838c18786924430cc5c
Author: weige <[email protected]>
Date:   Fri Nov 1 17:28:20 2024 +0800

    add bt install doc

commit d66bfc6352fd2aea34eaaeeb15e109206549b75e
Merge: 36bfa2ef 4d75b23e
Author: Dogtiti <[email protected]>
Date:   Fri Nov 1 14:16:50 2024 +0800

    Merge pull request #5752 from ConnectAI-E/feat-glm

    fix: ts error

commit 4d75b23ed1b41a042e28805e46ad2b5c8111cc3d
Author: DDMeaqua <[email protected]>
Date:   Fri Nov 1 14:15:12 2024 +0800

    fix: ts error

commit 36bfa2ef7c4638c55fe12579f7751310db1f422c
Merge: 0581e372 afe12c21
Author: Dogtiti <[email protected]>
Date:   Fri Nov 1 13:57:30 2024 +0800

    Merge pull request #5741 from ConnectAI-E/feat-glm

    feat: [#5714] 支持GLM

commit afe12c212e51bd2d27c5db5700f881c32a0bd3ba
Author: DDMeaqua <[email protected]>
Date:   Fri Nov 1 13:53:43 2024 +0800

    chore: update

commit adf97c6d8bbce8c705437fb8251b87eea574e755
Merge: 7c466c9b 0581e372
Author: GH Action - Upstream Sync <[email protected]>
Date:   Fri Nov 1 01:18:59 2024 +0000

    Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web

commit 7a8d557ea37e9b02fc26d8416fc631f4b7adda56
Author: DDMeaqua <[email protected]>
Date:   Thu Oct 31 11:37:19 2024 +0800

    chore: 开启插件

commit d3f0a77830073684dd8da25e34d5d8eb0a94ecdb
Author: DDMeaqua <[email protected]>
Date:   Thu Oct 31 11:23:06 2024 +0800

    chore: update Provider

commit 0581e37236a11b7d7925be25fe44320445914f7e
Merge: a0fa4d7e 44383a8b
Author: Dogtiti <[email protected]>
Date:   Thu Oct 31 11:19:34 2024 +0800

    Merge pull request #5744 from mrcore/main

    add  claude-3-5-sonnet-latest and claude-3-opus-latest

commit 44383a8b331ed283f06213c5176bf60fe98bbcc0
Author: Core <[email protected]>
Date:   Thu Oct 31 11:00:45 2024 +0800

    add  claude-3-5-sonnet-latest and claude-3-opus-latest

    add  claude-3-5-sonnet-latest and claude-3-opus-latest

commit 7c466c9b9c29a1823a19c05aeba4ba2f348e8455
Merge: b0d28eb7 a0fa4d7e
Author: GH Action - Upstream Sync <[email protected]>
Date:   Thu Oct 31 01:14:28 2024 +0000

    Merge branch 'main' of https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web

commit a0fa4d7e7251c66e048825d770f8b107095191e7
Merge: d0bd1bf8 736cbdbd
Author: Dogtiti <[email protected]>
Date:   Thu Oct 31 00:13:16 2024 +0800

    Merge pull request #5737 from hyiip/claude3.5

    add constant to claude 3.5 sonnet 20241022

commit d357b45e84eb773c2e0c142d0d849c4f20be2975
Author: DDMeaqua <[email protected]>
Date:   Wed Oct 30 19:24:03 2024 +0800

    feat: [#5714] 支持GLM

commit d0bd1bf8fd1a87ede56859b3d5b6a64e8ce461d2
Merge: 613d67ea 86ffa1e6
Author: Lloyd Zhou <[email protected]>
Date:   Wed Oct 30 16:56:53 2024 +0800

    Merge pull request #5740 from yuxuan-ctrl/main

    feat: 新增阿里系模型代码配置

commit 86ffa1e6430b0a34893665bb284130c1f144e399
Author: yuxuan-ctrl <[email protected]>
Date:   Wed Oct 30 16:30:01 2024 +0800

    feat: 新增阿里系模型代码配置

commit b0d28eb77ebec3a58f57605fb79fdf38e282e22a
Merge: 064e964d 613d67ea
Author: endless-learner <[email protected]>
Date:   Tue Oct 29 14:38:49 2024 -0700

    Merge branch 'main' into main

commit 736cbdbdd12d340e9b08b69724f9a1321befd645
Author: hyiip <[email protected]>
Date:   Wed Oct 30 02:18:41 2024 +0800

    add constant to claude 3.5 sonnet 20241022

commit 613d67eada996176335142cc2486bfe09be66700
Merge: 56bc77d2 89cea189
Author: Dogtiti <[email protected]>
Date:   Tue Oct 29 19:39:59 2024 +0800

    Merge pull request #5729 from ConnectAI-E/feature/jest

    chore: improve jest

commit 89cea18955a6d3ac73d053014f9f0d70338623e8
Merge: 49d42bb4 56bc77d2
Author: Dogtiti <[email protected]>
Date:   Tue Oct 29 19:26:52 2024 +0800

    Merge branch 'main' of https://github.com/ConnectAI-E/ChatGPT-Next-Web into feature/jest

commit 56bc77d20bc102af8166c48c8406f11f82cd4cae
Merge: 6d93d379 a4d7a2c6
Author: Dogtiti <[email protected]>
Date:   Mon Oct 28 21:52:08 2024 +0800

    Merge pull request #5731 from ChatGPTNextWeb/dependabot/npm_and_yarn/testing-library/jest-dom-6.6.2

    Bump @testing-library/jest-dom from 6.4.8 to 6.6.2

commit 6d93d37963faf087bc21dea147fe2e9b0e96cee7
Merge: 4f496263 24df85cf
Author: Dogtiti <[email protected]>
Date:   Mon Oct 28 21:51:59 2024 +0800

    Merge pull request #5732 from ChatGPTNextWeb/dependabot/npm_and_yarn/types/jest-29.5.14

    Bump @types/jest from 29.5.13 to 29.5.14

commit 24df85cf9d3ab2a307baa1539922c9463949ffa9
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Oct 28 10:31:34 2024 +0000

    Bump @types/jest from 29.5.13 to 29.5.14

    Bumps [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/jest) from 29.5.13 to 29.5.14.
    - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
    - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/jest)

    ---
    updated-dependencies:
    - dependency-name: "@types/jest"
      dependency-type: direct:development
      update-type: version-update:semver-patch
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

commit a4d7a2c6e3ef4d325a8039b5dd5bb9445d496c02
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Oct 28 10:31:27 2024 +0000

    Bump @testing-library/jest-dom from 6.4.8 to 6.6.2

    Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 6.4.8 to 6.6.2.
    - [Release notes](https://github.com/testing-library/jest-dom/releases)
    - [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/testing-library/jest-dom/compare/v6.4.8...v6.6.2)

    ---
    updated-dependencies:
    - dependency-name: "@testing-library/jest-dom"
      dependency-type: direct:development
      update-type: version-update:semver-minor
    ...

    Signed-off-by: dependabot[bot] <[email protected]>

commit 49d42bb45d50141c6f7321ea650b0c5d58697591
Author: Dogtiti <[email protected]>
Date:   Mon Oct 28 16:47:05 2024 +0800

    chore: improve jest

commit 4f49626303127cac6f66ab9386d5b5076ed4d1d1
Merge: 82994843 45db20c1
Author: Lloyd Zhou <[email protected]>
Date:   Sat Oct 26 12:09:09 2024 +0800

    Merge pull request #5722 from ElricLiu/main

    Update README.md

commit 45db20c1c37279ebfe610d75a80dc09a21a14c54
Author: ElricLiu <[email protected]>
Date:   Sat Oct 26 11:16:43 2024 +0800

    Update README.md

commit 82994843f5f9923d8c1c7e4b9e4f6ab79fb17110
Merge: 1110a087 90ced928
Author: Lloyd Zhou <[email protected]>
Date:   Fri Oct 25 20:34:15 2024 +0800

    Merge pull request #5719 from ConnectAI-E/hotfix/status_text_error

    hotfix for statusText is non ISO-8859-1 #5717

commit 1110a087a0268a7b8a523c547698b961dbd478b6
Merge: 4745706c f0b3e10a
Author: Dogtiti <[email protected]>
Date:   Fri Oct 25 18:25:46 2024 +0800

    Merge pull request #5720 from ConnectAI-E/hotfix/gemini_invald_argument

    hotfix for gemini invald argument #5715

commit f0b3e10a6caf55bf91325183b5ad84de2a05db04
Author: lloydzhou <[email protected]>
Date:   Fri Oct 25 18:19:22 2024 +0800

    hotfix for gemini invald argument #5715

commit f89872b833d27c48b33281e60157640037e17a99
Author: lloydzhou <[email protected]>
Date:   Fri Oct 25 18:12:09 2024 +0800

    hotfix for gemini invald argument #5715

commit 90ced9287626492898f2eb9bfd3b079171faf6ea
Author: lloydzhou <[email protected]>
Date:   Fri Oct 25 18:05:29 2024 +0800

    update

commit 2c745590101b5201c677243f151616cb7023186e
Author: lloydzhou <[email protected]>
Date:   Fri Oct 25 18:02:51 2024 +0800

    hitfix

commit e3ca7e8b4433bea43376035b9417fe233fe5f6f0
Author: lloydzhou <[email protected]>
Date:   Fri Oct 25 17:52:08 2024 +0800

    hotfix for statusText is non ISO-8859-1 #5717

commit 4745706c42a390117e5e0f700af3d5f06e18f312
Author: lloydzhou <[email protected]>
Date:   Thu Oct 24 15:32:27 2024 +0800

    update version to v2.15.6

commit 801dc412f99937dfd64a895309d9304429d94cac
Author: lloydzhou <[email protected]>
Date:   Thu Oct 24 15:28:05 2024 +0800

    add claude-3.5-haiku

commit c7c2c0211a8b8906dc8b2de695bb74c6b22da92e
Merge: 06f897f3 65bb962f
Author: Dogtiti <[email protected]>
Date:   Wed Oct 23 14:13:17 2024 +0800

    Merge pull request #5704 from ConnectAI-E/feature/xai

    xAi support

commit 65bb962fc0b6eaa0cb1e15451d954df216b1956f
Author: lloydzhou <[email protected]>
Date:   Wed Oct 23 12:00:59 2024 +0800

    hotfix

commit e791cd441d544a18126ddb825651d0e627402…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wip
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants