这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@homanp
Copy link
Contributor

@homanp homanp commented Jul 25, 2025

What does this PR do?

This pull request introduces support for MCP (Model Context Protocol) tools, enabling the Grok CLI to integrate with external services like Linear and GitHub. The changes include updates to the CLI, core agent logic, and configuration management to support MCP servers and tools. Below are the most significant changes:

Enhancements to CLI and User Documentation

  • README.md: Added a new section on MCP tools, including usage instructions, examples for adding servers, and details on available transport types (stdio, http, sse). [1] [2]
  • New MCP CLI Commands: Introduced commands for managing MCP servers (add, add-json, remove, list, test) via the src/commands/mcp.ts module. These commands allow users to configure and interact with MCP servers directly from the CLI.

Core Agent Updates

  • MCP Initialization: Added methods to GrokAgent for initializing MCP servers (initializeMCP) and ensuring MCP readiness before processing user messages. This includes loading configuration, connecting to servers, and handling errors gracefully. [1] [2]
  • Dynamic Tool Loading: Updated GrokAgent to dynamically load tools, including MCP tools, using the getAllGrokTools method. This ensures that tools from MCP servers are seamlessly integrated into the agent's capabilities. [1] [2]

Tool Execution and Management

  • MCP Tool Execution: Added logic to execute MCP-specific tools in GrokAgent, parsing arguments and handling results or errors. [1] [2]
  • Tool Conversion: Implemented utility functions in src/grok/tools.ts to convert MCP tools into Grok-compatible tools and merge them with existing tools. [1] [2]

Dependency and Configuration Updates

  • Dependencies: Added the @modelcontextprotocol/sdk library to package.json for MCP support.
  • Configuration Management: Introduced logic to load MCP server configurations and manage their lifecycle, including connection and error handling.

Integration with Main CLI

  • CLI Entry Point: Registered the new MCP command in the main CLI program (src/index.ts), making it accessible to users. [1] [2]

Fixes #17

Checklist

  • I tested my changes
  • I reviewed my own code

@homanp homanp self-assigned this Jul 25, 2025
@homanp homanp changed the title Feat/mcp tools feat: add support for mcp Jul 25, 2025
@homanp homanp merged commit 9c1d82b into main Jul 25, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP Support (PR 18)

2 participants