mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-06-19 04:03:45 +08:00
Introduce support for Model Context Protocol (MCP) servers in the discourse-ai plugin, allowing AI agents to connect to external tool servers via the MCP standard. Key additions: - AiMcpServer model with CRUD admin UI, health tracking, and tool caching (hourly refresh via scheduled job) - MCP client (Streamable HTTP transport) with session management and tool invocation - Full OAuth 2.1 flow support (discovery, dynamic registration, authorization code grant, token refresh, and disconnect) - MCP tool type for AI agents that proxies tool calls to remote MCP servers at runtime - Agent editor updated to show combined tool/token counts from both local tools and MCP servers - Agent import/export includes MCP server associations - Admin secrets UI updated to surface MCP server usage - Comprehensive specs for models, controllers, client, tool registry, and OAuth flow
27 lines
1,015 B
Ruby
Vendored
27 lines
1,015 B
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class CreateAiMcpServers < ActiveRecord::Migration[7.2]
|
|
def change
|
|
create_table :ai_mcp_servers do |t|
|
|
t.string :name, null: false, limit: 100
|
|
t.string :description, null: false, limit: 1000
|
|
t.string :url, null: false, limit: 1000
|
|
t.bigint :ai_secret_id
|
|
t.string :auth_header, null: false, limit: 100, default: "Authorization"
|
|
t.string :auth_scheme, null: false, limit: 100, default: "Bearer"
|
|
t.boolean :enabled, null: false, default: true
|
|
t.integer :timeout_seconds, null: false, default: 30
|
|
t.string :last_health_status, limit: 50
|
|
t.string :last_health_error, limit: 1000
|
|
t.datetime :last_checked_at
|
|
t.datetime :last_tools_synced_at
|
|
t.jsonb :server_capabilities, null: false, default: {}
|
|
t.string :protocol_version, limit: 100
|
|
t.integer :created_by_id
|
|
t.timestamps
|
|
end
|
|
|
|
add_index :ai_mcp_servers, :name, unique: true
|
|
add_index :ai_mcp_servers, :ai_secret_id
|
|
end
|
|
end
|