Skip to content

Conversation

samuv
Copy link
Collaborator

@samuv samuv commented Aug 14, 2025

FYI: This is just a POC under feature flag playground

Kapture.2025-08-14.at.18.12.12.mp4

AI SDK Chat Integration with MCP Support

This PR reworks the chat system to use the AI SDK and fully integrates with MCP servers (via ToolHive). The goal was to build a solid, stream-based chat experience that can interact with external tools in real-time, across multiple providers.

What’s new

AI SDK & Chat Streaming
• Switched over to the AI SDK’s streamText API to handle streaming messages.
• Built a custom ChatTransport over Electron IPC to bridge streaming between the backend and frontend.
• Used useChat on the frontend to plug into the new stream and render live updates in the UI.
• Added full metadata to messages (timestamps, model name, token usage, etc.) for better visibility.

MCP Integration
• The app can now dynamically discover tools from MCP servers and expose them in the UI.
• Tool descriptions, input parameters, and execution states are all shown and updated live.
• Each server can have its own set of tools enabled/disabled, and that state is persisted.
• Errors with tool execution or server connectivity are handled gracefully.

Providers
• Supports OpenAI, Anthropic, and OpenRouter (with their full model lists).
• Provider selection is integrated into the chat UI with a searchable dropdown.
• Each provider shares the same interface, so switching is seamless from the user’s point of view.

@samuv samuv self-assigned this Aug 14, 2025
@Copilot Copilot AI review requested due to automatic review settings August 14, 2025 16:19
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a comprehensive chat system using the AI SDK to enable streaming conversations with multiple AI providers and full MCP (Model Context Protocol) server integration. The implementation provides real-time streaming, tool execution, and a polished UI for interacting with external tools via ToolHive.

  • Implements streaming chat interface using AI SDK with real-time IPC communication between frontend and backend
  • Adds support for multiple AI providers (OpenAI, Anthropic, Google, xAI, OpenRouter) with dynamic model discovery
  • Integrates MCP server tools for enhanced AI capabilities with tool selection and execution tracking

Reviewed Changes

Copilot reviewed 33 out of 34 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
renderer/src/routes/playground.tsx Creates new playground route with chat interface
renderer/src/route-tree.gen.ts Generated route tree updates for playground
renderer/src/features/chat/ Complete chat feature implementation with types, hooks, components
renderer/src/common/components/ui/collapsible.tsx Adds collapsible UI component for tool management
renderer/src/common/components/layout/top-nav/index.tsx Adds playground navigation link
preload/src/preload.ts Exposes chat-related IPC methods to renderer
package.json Adds AI SDK dependencies and related packages
main/src/main.ts Implements chat IPC handlers
main/src/chat/ Backend chat implementation with providers, tools, storage, streaming

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@samuv samuv changed the title feat: Playground Experimental Chat feat: playground Experimental Chat Aug 14, 2025
@samuv samuv changed the title feat: playground Experimental Chat feat: playground experimental chat Aug 14, 2025
@samuv samuv changed the title feat: playground experimental chat feat(feature-flag): playground experimental chat Aug 19, 2025
@samuv samuv merged commit 9ab4205 into main Aug 19, 2025
14 checks passed
@samuv samuv deleted the playground branch August 19, 2025 22:57
LiamStorkey pushed a commit to liamstorkey-elmo/toolhive-studio that referenced this pull request Aug 19, 2025
* feat: initial playground

* refactor: complete refactor and overhaul

* enable pre-release

* fix: adjust unused var, code and deps

* feat: use tenstack query for feature flags and put playground around it

* revert: remove prerelease true
@samuv samuv linked an issue Aug 21, 2025 that may be closed by this pull request
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.

[Task] UI playground POC
2 participants