Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(codex): render GitHub MCP tool calls (#16449)

Arvin Xueb5e72e0a077
diff --git a/locales/en-US/plugin.json b/locales/en-US/plugin.json
index 3d927e6daf4..1637893ce7b 100644
--- a/locales/en-US/plugin.json
+++ b/locales/en-US/plugin.json
@@ -29,6 +29,9 @@
"builtins.codex.mcpTool.result": "Result",
"builtins.codex.mcpTool.unknownTool": "MCP tool",
"builtins.codex.webSearch.query": "Query",
+ "builtins.github.render.error": "Error",
+ "builtins.github.render.rawResult": "Raw result",
+ "builtins.github.render.updatedAt": "Updated {{time}}",
"builtins.linear.render.updatedAt": "Updated {{time}}",
"builtins.lobe-activator.apiName.activateTools": "Activate Tools",
"builtins.lobe-activator.inspector.activateTools.notFoundCount": "{{count}} not found",
diff --git a/locales/zh-CN/plugin.json b/locales/zh-CN/plugin.json
index 36fc06b6066..59b4c45335e 100644
--- a/locales/zh-CN/plugin.json
+++ b/locales/zh-CN/plugin.json
@@ -29,6 +29,9 @@
"builtins.codex.mcpTool.result": "结果",
"builtins.codex.mcpTool.unknownTool": "MCP 工具",
"builtins.codex.webSearch.query": "搜索词",
+ "builtins.github.render.error": "错误",
+ "builtins.github.render.rawResult": "原始结果",
+ "builtins.github.render.updatedAt": "更新于 {{time}}",
"builtins.linear.render.updatedAt": "更新于 {{time}}",
"builtins.lobe-activator.apiName.activateTools": "激活工具",
"builtins.lobe-activator.inspector.activateTools.notFoundCount": "{{count}} 个未找到",
diff --git a/packages/builtin-tools/src/codex/McpToolInspector.tsx b/packages/builtin-tools/src/codex/McpToolInspector.tsx
index 88e21c3f7e7..e78cbcdd022 100644
--- a/packages/builtin-tools/src/codex/McpToolInspector.tsx
+++ b/packages/builtin-tools/src/codex/McpToolInspector.tsx
@@ -1,6 +1,10 @@
'use client';
-import { LINEAR_TOOL_NAMES, LinearInspector } from '@lobechat/shared-tool-ui/inspectors';
+import {
+ GitHubInspector,
+ LINEAR_TOOL_NAMES,
+ LinearInspector,
+} from '@lobechat/shared-tool-ui/inspectors';
import {
highlightTextStyles,
inspectorTextStyles,
@@ -14,6 +18,7 @@ import { useTranslation } from 'react-i18next';
import type { CodexMcpToolArgs, CodexMcpToolState } from './mcpToolUtils';
import {
+ getCodexGithubMcpApiName,
getCodexLinearMcpApiName,
getMcpInputRecord,
getMcpServer,
@@ -24,6 +29,9 @@ const LINEAR_TOOL_NAME_SET = new Set<string>([...LINEAR_TOOL_NAMES, 'fetch', 'se
const SharedLinearInspector = LinearInspector as ComponentType<
BuiltinInspectorProps<Record<string, unknown>>
>;
+const SharedGitHubInspector = GitHubInspector as ComponentType<
+ BuiltinInspectorProps<Record<string, unknown>>
+>;
const McpToolInspector = memo<BuiltinInspectorProps<CodexMcpToolArgs, CodexMcpToolState>>(
({ args, partialArgs, isArgumentsStreaming, isLoading, pluginState }) => {
@@ -40,6 +48,10 @@ const McpToolInspector = memo<BuiltinInspectorProps<CodexMcpToolArgs, CodexMcpTo
server,
toolName: tool,
});
+ const githubApiName = getCodexGithubMcpApiName({
+ server,
+ toolName: tool,
+ });
if (LINEAR_TOOL_NAME_SET.has(linearApiName)) {
return (
@@ -55,6 +67,20 @@ const McpToolInspector = memo<BuiltinInspectorProps<CodexMcpToolArgs, CodexMcpTo
);
}
+ if (githubApiName) {
+ return (
+ <SharedGitHubInspector
+ apiName={githubApiName}
+ args={input || {}}
+ identifier={'codex'}
+ isArgumentsStreaming={isArgumentsStreaming}
+ isLoading={isLoading}
+ partialArgs={partialInput || {}}
+ pluginState={pluginState}
+ />
+ );
+ }
+
const target = [server, tool].filter(Boolean).join(' > ');
if (isArgumentsStreaming && !target) {
diff --git a/packages/builtin-tools/src/codex/McpToolRender.tsx b/packages/builtin-tools/src/codex/McpToolRender.tsx
index deef446ac01..9e19cba834c 100644
--- a/packages/builtin-tools/src/codex/McpToolRender.tsx
+++ b/packages/builtin-tools/src/codex/McpToolRender.tsx
@@ -1,7 +1,7 @@
'use client';
import { LINEAR_TOOL_NAMES } from '@lobechat/shared-tool-ui/inspectors';
-import { LinearRender } from '@lobechat/shared-tool-ui/renders';
+import { GitHubRender, LinearRender } from '@lobechat/shared-tool-ui/renders';
import type { BuiltinRenderProps } from '@lobechat/types';
import { Flexbox, Highlighter, Text } from '@lobehub/ui';
import { createStaticStyles, cssVar } from 'antd-style';
@@ -13,6 +13,7 @@ import type { CodexMcpToolArgs, CodexMcpToolState } from './mcpToolUtils';
import {
formatMcpInput,
formatMcpOutput,
+ getCodexGithubMcpApiName,
getCodexLinearMcpApiName,
getMcpErrorText,
getMcpInput,
@@ -34,6 +35,9 @@ const LINEAR_TOOL_NAME_SET = new Set<string>([...LINEAR_TOOL_NAMES, 'fetch', 'se
const SharedLinearRender = LinearRender as ComponentType<
BuiltinRenderProps<Record<string, unknown>, unknown, string>
>;
+const SharedGitHubRender = GitHubRender as ComponentType<
+ BuiltinRenderProps<Record<string, unknown>, unknown, string>
+>;
const McpToolRender = memo<BuiltinRenderProps<CodexMcpToolArgs, CodexMcpToolState, string>>(
({ args, content, messageId, pluginState, toolCallId }) => {
@@ -48,6 +52,10 @@ const McpToolRender = memo<BuiltinRenderProps<CodexMcpToolArgs, CodexMcpToolStat
server,
toolName,
});
+ const githubApiName = getCodexGithubMcpApiName({
+ server,
+ toolName,
+ });
if (LINEAR_TOOL_NAME_SET.has(linearApiName)) {
return (
@@ -64,6 +72,21 @@ const McpToolRender = memo<BuiltinRenderProps<CodexMcpToolArgs, CodexMcpToolStat
);
}
+ if (githubApiName) {
+ return (
+ <SharedGitHubRender
+ apiName={githubApiName}
+ args={inputRecord || {}}
+ content={resultText}
+ identifier={'codex'}
+ messageId={messageId}
+ pluginError={error}
+ pluginState={pluginState}
+ toolCallId={toolCallId}
+ />
+ );
+ }
+
const input = formatMcpInput(getMcpInput(args, pluginState), toolName);
const output = formatMcpOutput(resultText, toolName);
diff --git a/packages/builtin-tools/src/codex/mcpToolUtils.test.ts b/packages/builtin-tools/src/codex/mcpToolUtils.test.ts
index d1364642f08..86cdf588cc7 100644
--- a/packages/builtin-tools/src/codex/mcpToolUtils.test.ts
+++ b/packages/builtin-tools/src/codex/mcpToolUtils.test.ts
@@ -1,6 +1,10 @@
import { describe, expect, it } from 'vitest';
-import { getCodexLinearMcpApiName, getMcpInputRecord } from './mcpToolUtils';
+import {
+ getCodexGithubMcpApiName,
+ getCodexLinearMcpApiName,
+ getMcpInputRecord,
+} from './mcpToolUtils';
describe('getCodexLinearMcpApiName', () => {
it('maps Codex Apps fetch calls to entity-specific Linear APIs', () => {
@@ -40,9 +44,9 @@ describe('getCodexLinearMcpApiName', () => {
});
it('treats bare issue identifiers as issue fetch calls', () => {
- expect(
- getCodexLinearMcpApiName({ input: { id: 'TEST-0000' }, toolName: 'linear_fetch' }),
- ).toBe('get_issue');
+ expect(getCodexLinearMcpApiName({ input: { id: 'TEST-0000' }, toolName: 'linear_fetch' })).toBe(
+ 'get_issue',
+ );
});
it('does not treat generic fetch or search from other MCP servers as Linear', () => {
@@ -90,6 +94,36 @@ describe('getCodexLinearMcpApiName', () => {
});
});
+describe('getCodexGithubMcpApiName', () => {
+ it('normalizes Codex Apps GitHub tool names', () => {
+ expect(
+ getCodexGithubMcpApiName({
+ server: 'mcp__codex_apps__github',
+ toolName: 'github_create_pull_request',
+ }),
+ ).toBe('create_pull_request');
+ expect(getCodexGithubMcpApiName({ toolName: 'github_update_issue' })).toBe('update_issue');
+ expect(getCodexGithubMcpApiName({ toolName: 'server_github_get_repository' })).toBe(
+ 'get_repository',
+ );
+ });
+
+ it('allows bare tool names only from a GitHub server', () => {
+ expect(
+ getCodexGithubMcpApiName({
+ server: 'mcp__codex_apps__github',
+ toolName: 'create_pull_request',
+ }),
+ ).toBe('create_pull_request');
+ expect(
+ getCodexGithubMcpApiName({
+ server: 'mcp__codex_apps__linear',
+ toolName: 'create_pull_request',
+ }),
+ ).toBe('');
+ });
+});
+
describe('getMcpInputRecord', () => {
it('parses JSON string MCP arguments', () => {
expect(getMcpInputRecord({ arguments: '{"id":"issue:TEST-0000"}' })).toEqual({
diff --git a/packages/builtin-tools/src/codex/mcpToolUtils.ts b/packages/builtin-tools/src/codex/mcpToolUtils.ts
index c6c105d2305..ae23064f9f0 100644
--- a/packages/builtin-tools/src/codex/mcpToolUtils.ts
+++ b/packages/builtin-tools/src/codex/mcpToolUtils.ts
@@ -24,6 +24,8 @@ export interface FormattedMcpValue {
const LINEAR_CODEX_PREFIX = 'linear_';
const LINEAR_CODEX_SERVER_PREFIX = 'server_';
+const GITHUB_CODEX_PREFIX = 'github_';
+const GITHUB_CODEX_SERVER_PREFIX = 'server_github_';
const CODEX_LINEAR_FETCH_API_BY_ENTITY: Record<string, string> = {
document: 'get_document',
initiative: 'get_initiative',
@@ -119,11 +121,51 @@ const normalizeCodexLinearToolName = (toolName: string) => {
return { apiName, hasLinearPrefix };
};
+const normalizeCodexGithubToolName = (toolName: string) => {
+ if (!toolName) return { apiName: '', hasGithubPrefix: false };
+
+ let apiName = toolName
+ .trim()
+ .replaceAll(/([a-z0-9])([A-Z])/g, '$1_$2')
+ .replaceAll(/[-\s]+/g, '_')
+ .toLowerCase();
+ let hasGithubPrefix = false;
+
+ let changed = true;
+ while (changed) {
+ changed = false;
+
+ if (apiName.startsWith(GITHUB_CODEX_SERVER_PREFIX)) {
+ apiName = apiName.slice(GITHUB_CODEX_SERVER_PREFIX.length);
+ hasGithubPrefix = true;
+ changed = true;
+ }
+
+ if (apiName.startsWith(GITHUB_CODEX_PREFIX)) {
+ apiName = apiName.slice(GITHUB_CODEX_PREFIX.length);
+ hasGithubPrefix = true;
+ changed = true;
+ }
+
+ while (apiName.startsWith('_')) {
+ apiName = apiName.slice(1);
+ changed = true;
+ }
+ }
+
+ return { apiName, hasGithubPrefix };
+};
+
const isLinearServerName = (server?: string) =>
normalizeString(server)
.split(/[^a-z0-9]+/iu)
.some((part) => part.toLowerCase() === 'linear');
+const isGithubServerName = (server?: string) =>
+ normalizeString(server)
+ .split(/[^a-z0-9]+/iu)
+ .some((part) => part.toLowerCase() === 'github');
+
const getCodexLinearFetchApiName = (
input: Record<string, unknown> | undefined,
isLinearContext: boolean,
@@ -158,6 +200,19 @@ export const getCodexLinearMcpApiName = ({
return apiName;
};
+export const getCodexGithubMcpApiName = ({
+ server,
+ toolName,
+}: {
+ server?: string;
+ toolName: string;
+}) => {
+ const { apiName, hasGithubPrefix } = normalizeCodexGithubToolName(toolName);
+ const isGithubContext = hasGithubPrefix || isGithubServerName(server);
+
+ return isGithubContext ? apiName : '';
+};
+
const stringifyValue = (value: unknown): string => {
if (typeof value === 'string') return value.trim();
if (value === undefined || value === null) return '';
diff --git a/packages/builtin-tools/src/github/index.ts b/packages/builtin-tools/src/github/index.ts
index 67b9b8f0c4e..3c4828c1906 100644
--- a/packages/builtin-tools/src/github/index.ts
+++ b/packages/builtin-tools/src/github/index.ts
@@ -1,3 +1,5 @@
+import { GITHUB_TOOL_NAMES, GitHubInspector } from '@lobechat/shared-tool-ui/inspectors';
+import { GitHubRender as SharedGitHubRender } from '@lobechat/shared-tool-ui/renders';
import { type BuiltinInspector, type BuiltinRender } from '@lobechat/types';
import GithubRunCommandInspector from './RunCommandInspector';
@@ -9,15 +11,31 @@ export const GithubApiName = {
runCommand: 'runCommand',
} as const;
+const GithubToolInspectors = Object.fromEntries(
+ GITHUB_TOOL_NAMES.flatMap((name) => [
+ [name, GitHubInspector],
+ [`github_${name}`, GitHubInspector],
+ ]),
+) as Record<string, BuiltinInspector>;
+
+const GithubToolRenders = Object.fromEntries(
+ GITHUB_TOOL_NAMES.flatMap((name) => [
+ [name, SharedGitHubRender],
+ [`github_${name}`, SharedGitHubRender],
+ ]),
+) as Record<string, BuiltinRender>;
+
// The tool call emits the camelCase `runCommand` apiName, while older payloads
// used the snake_case `run_command`. Register both so the render/inspector match
// regardless of the casing.
export const GithubInspectors: Record<string, BuiltinInspector> = {
+ ...GithubToolInspectors,
runCommand: GithubRunCommandInspector as BuiltinInspector,
run_command: GithubRunCommandInspector as BuiltinInspector,
};
export const GithubRenders: Record<string, BuiltinRender> = {
+ ...GithubToolRenders,
runCommand: GithubRunCommandRender as BuiltinRender,
run_command: GithubRunCommandRender as BuiltinRender,
};
diff --git a/packages/locales/src/default/plugin.ts b/packages/locales/src/default/plugin.ts
index cd613b248e2..f5e8904d05f 100644
--- a/packages/locales/src/default/plugin.ts
+++ b/packages/locales/src/default/plugin.ts
@@ -110,6 +110,10 @@ export default {
'builtins.codex.mcpTool.result': 'Result',
'builtins.codex.mcpTool.unknownTool': 'MCP tool',
'builtins.codex.webSearch.query': 'Query',
+ 'builtins.github.render.error': 'Error',
+ 'builtins.github.render.rawResult': 'Raw result',
+ 'builtins.github.render.updatedAt': 'Updated {{time}}',
+ 'builtins.linear.render.updatedAt': 'Updated {{time}}',
'builtins.lobe-cloud-sandbox.apiName.editFile': 'Edit file',
'builtins.lobe-cloud-sandbox.apiName.executeCode': 'Execute code',
'builtins.lobe-cloud-sandbox.apiName.exportFile': 'Export file',
@@ -317,7 +321,6 @@ export default {
'builtins.lobe-page-agent.apiName.updateNode': 'Update node',
'builtins.lobe-page-agent.apiName.wrapNodes': 'Wrap nodes',
'builtins.lobe-page-agent.title': 'Page',
- 'builtins.linear.render.updatedAt': 'Updated {{time}}',
'builtins.lobe-activator.apiName.activateTools': 'Activate Tools',
'builtins.lobe-activator.inspector.activateTools.notFoundCount': '{{count}} not found',
'builtins.lobe-skill-store.apiName.importFromMarket': 'Import from Market',
diff --git a/packages/shared-tool-ui/package.json b/packages/shared-tool-ui/package.json
index ab639883891..aec1cb01798 100644
--- a/packages/shared-tool-ui/package.json
+++ b/packages/shared-tool-ui/package.json
@@ -5,9 +5,10 @@
"exports": {
".": "./src/index.ts",
"./components": "./src/components/index.ts",
- "./renders": "./src/Render/index.ts",
"./inspectors": "./src/Inspector/index.ts",
+ "./inspectors/github-labels": "./src/Inspector/GitHub/labels.ts",
"./inspectors/linear-labels": "./src/Inspector/Linear/labels.ts",
+ "./renders": "./src/Render/index.ts",
"./styles": "./src/styles.ts"
},
"dependencies": {
diff --git a/packages/shared-tool-ui/src/Inspector/GitHub/Inspector.tsx b/packages/shared-tool-ui/src/Inspector/GitHub/Inspector.tsx
new file mode 100644
index 00000000000..3a8e9675224
--- /dev/null
+++ b/packages/shared-tool-ui/src/Inspector/GitHub/Inspector.tsx
@@ -0,0 +1,259 @@
+'use client';
+
+import type { BuiltinInspector, BuiltinInspectorProps } from '@lobechat/types';
+import { createStaticStyles, cx } from 'antd-style';
+import { GitBranch, Hash } from 'lucide-react';
+import { memo } from 'react';
+
+import { inspectorTextStyles, shinyTextStyles } from '../../styles';
+import { parseGitHubToolName, staticGitHubLabelFor } from './labels';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ branchBadge: css`
+ display: inline-flex;
+ flex-shrink: 0;
+ gap: 4px;
+ align-items: center;
+
+ min-width: 0;
+ margin-inline-start: 6px;
+ padding-block: 2px;
+ padding-inline: 8px;
+ border-radius: 999px;
+
+ font-family: ${cssVar.fontFamilyCode};
+ font-size: 12px;
+ color: ${cssVar.colorText};
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ branchBadgeText: css`
+ overflow: hidden;
+ max-width: 220px;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ `,
+ chip: css`
+ overflow: hidden;
+ display: inline-flex;
+ flex-shrink: 1;
+ align-items: stretch;
+
+ min-width: 0;
+ margin-inline-start: 6px;
+ border-radius: 999px;
+
+ font-size: 12px;
+ line-height: 18px;
+
+ background: ${cssVar.colorFillTertiary};
+ `,
+ chipAction: css`
+ flex-shrink: 0;
+ padding-block: 2px;
+ padding-inline: 10px;
+ color: ${cssVar.colorText};
+ `,
+ chipDivider: css`
+ flex-shrink: 0;
+ align-self: stretch;
+ width: 1px;
+ background: ${cssVar.colorBorderSecondary};
+ `,
+ chipIcon: css`
+ flex-shrink: 0;
+ color: ${cssVar.colorTextDescription};
+ `,
+ chipKey: css`
+ color: ${cssVar.colorTextDescription};
+ `,
+ chipValue: css`
+ overflow: hidden;
+ display: inline-flex;
+ flex-shrink: 1;
+ gap: 4px;
+ align-items: center;
+
+ min-width: 0;
+ padding-block: 2px;
+ padding-inline: 10px;
+
+ font-family: ${cssVar.fontFamilyCode};
+ color: ${cssVar.colorText};
+ `,
+ chipValueText: css`
+ overflow: hidden;
+ min-width: 0;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ `,
+ icon: css`
+ flex-shrink: 0;
+ margin-inline-end: 6px;
+ color: ${cssVar.colorTextDescription};
+ `,
+ productPrefix: css`
+ flex-shrink: 0;
+
+ margin-inline-end: 2px;
+
+ font-size: 13px;
+ font-weight: 500;
+ color: ${cssVar.colorTextSecondary};
+ `,
+}));
+
+const GitHubMark = memo<{ size?: number }>(({ size = 14 }) => (
+ <svg
+ aria-hidden="true"
+ className={styles.icon}
+ height={size}
+ viewBox="0 0 98 96"
+ width={size}
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M48.9 0C21.9 0 0 22 0 49.1c0 21.7 14 40.1 33.5 46.6 2.4.5 3.3-1.1 3.3-2.4 0-1.2-.1-5.2-.1-9.4-13.6 3-16.5-5.8-16.5-5.8-2.2-5.7-5.4-7.2-5.4-7.2-4.5-3.1.3-3 .3-3 4.9.3 7.5 5.1 7.5 5.1 4.4 7.5 11.5 5.3 14.3 4.1.4-3.2 1.7-5.3 3.1-6.6-10.9-1.2-22.3-5.5-22.3-24.3 0-5.4 1.9-9.8 5.1-13.2-.5-1.2-2.2-6.3.5-13 0 0 4.1-1.3 13.5 5 3.9-1.1 8.1-1.6 12.2-1.6s8.3.5 12.2 1.6c9.4-6.4 13.5-5 13.5-5 2.7 6.7 1 11.8.5 13 3.2 3.4 5.1 7.8 5.1 13.2 0 18.9-11.5 23.1-22.4 24.3 1.8 1.6 3.3 4.6 3.3 9.3 0 6.7-.1 12.1-.1 13.8 0 1.3.9 2.9 3.4 2.4C84 89.2 98 70.8 98 49.1 97.9 22 75.9 0 48.9 0Z"
+ fill="currentColor"
+ />
+ </svg>
+));
+GitHubMark.displayName = 'GitHubMark';
+
+interface Chip {
+ iconType?: 'number';
+ key?: string;
+ value: string;
+}
+
+interface ChipResult {
+ branch?: string;
+ primary: Chip | null;
+}
+
+const truncate = (value: string, max = 80): string =>
+ value.length > max ? `${value.slice(0, max - 1)}...` : value;
+
+const readString = (value: unknown): string | undefined => {
+ if (typeof value === 'string' && value.trim()) return value.trim();
+ if (typeof value === 'number') return String(value);
+ if (typeof value === 'object' && value && !Array.isArray(value)) {
+ const record = value as Record<string, unknown>;
+ for (const key of ['full_name', 'name', 'login', 'id']) {
+ const nested = readString(record[key]);
+ if (nested) return nested;
+ }
+ }
+};
+
+const stringArg = (args: Record<string, unknown> | undefined, key: string): string | undefined =>
+ readString(args?.[key]);
+
+const pickRepo = (args: Record<string, unknown> | undefined): string | undefined => {
+ if (!args) return;
+
+ const direct =
+ stringArg(args, 'repository_full_name') ||
+ stringArg(args, 'full_name') ||
+ stringArg(args, 'repository') ||
+ stringArg(args, 'repo');
+ if (direct) return direct;
+
+ const owner = stringArg(args, 'owner');
+ const name = stringArg(args, 'name');
+ return owner && name ? `${owner}/${name}` : undefined;
+};
+
+const pickNumber = (args: Record<string, unknown> | undefined): string | undefined =>
+ stringArg(args, 'pull_number') ||
+ stringArg(args, 'pullNumber') ||
+ stringArg(args, 'issue_number') ||
+ stringArg(args, 'issueNumber') ||
+ stringArg(args, 'number');
+
+const pickBranch = (args: Record<string, unknown> | undefined): string | undefined => {
+ if (!args) return;
+
+ const head = stringArg(args, 'head') || stringArg(args, 'head_ref');
+ const base = stringArg(args, 'base') || stringArg(args, 'base_ref');
+ if (head && base) return `${head} -> ${base}`;
+
+ return head || base || stringArg(args, 'branch') || stringArg(args, 'ref');
+};
+
+const pickPrimaryChip = (args: Record<string, unknown> | undefined): Chip | null => {
+ if (!args) return null;
+
+ const repo = pickRepo(args);
+ if (repo) return { key: 'repo', value: truncate(repo, 72) };
+
+ const number = pickNumber(args);
+ if (number) return { iconType: 'number', value: `#${number}` };
+
+ const title = stringArg(args, 'title') || stringArg(args, 'subject');
+ if (title) return { value: truncate(title, 72) };
+
+ const query = stringArg(args, 'query') || stringArg(args, 'q');
+ if (query) return { key: 'query', value: truncate(query, 72) };
+
+ const path = stringArg(args, 'path') || stringArg(args, 'file_path');
+ if (path) return { key: 'path', value: truncate(path, 72) };
+
+ for (const [key, value] of Object.entries(args)) {
+ if (typeof value === 'string' && value.length > 0) {
+ return { key, value: truncate(value, 72) };
+ }
+ }
+
+ return null;
+};
+
+const pickChip = (args: Record<string, unknown> | undefined): ChipResult => ({
+ branch: pickBranch(args),
+ primary: pickPrimaryChip(args),
+});
+
+const GitHubInspectorImpl = memo<BuiltinInspectorProps<Record<string, unknown>>>(
+ ({ apiName, args, partialArgs, isArgumentsStreaming, isLoading }) => {
+ const effectiveArgs = args ?? partialArgs;
+ const label = staticGitHubLabelFor(parseGitHubToolName(apiName));
+ const { branch, primary } = pickChip(effectiveArgs);
+
+ return (
+ <div
+ className={cx(
+ inspectorTextStyles.root,
+ (isArgumentsStreaming || isLoading) && shinyTextStyles.shinyText,
+ )}
+ >
+ <GitHubMark />
+ <span className={styles.productPrefix}>GitHub</span>
+ <span className={styles.chip}>
+ <span className={styles.chipAction}>{label}</span>
+ {primary && (
+ <>
+ <span className={styles.chipDivider} />
+ <span className={styles.chipValue}>
+ {primary.iconType === 'number' ? (
+ <Hash className={styles.chipIcon} size={12} />
+ ) : (
+ primary.key && <span className={styles.chipKey}>{primary.key}:</span>
+ )}
+ <span className={styles.chipValueText}>{primary.value}</span>
+ </span>
+ </>
+ )}
+ </span>
+ {branch && (
+ <span className={styles.branchBadge} title={branch}>
+ <GitBranch className={styles.chipIcon} size={12} />
+ <span className={styles.branchBadgeText}>{branch}</span>
+ </span>
+ )}
+ </div>
+ );
+ },
+);
+GitHubInspectorImpl.displayName = 'GitHubInspector';
+
+export const GitHubInspector = GitHubInspectorImpl as unknown as BuiltinInspector;
diff --git a/packages/shared-tool-ui/src/Inspector/GitHub/index.ts b/packages/shared-tool-ui/src/Inspector/GitHub/index.ts
new file mode 100644
index 00000000000..4cd6d608227
--- /dev/null
+++ b/packages/shared-tool-ui/src/Inspector/GitHub/index.ts
@@ -0,0 +1,8 @@
+export { GitHubInspector } from './Inspector';
+export {
+ getGitHubToolSuffix,
+ GITHUB_TOOL_NAMES,
+ isGitHubMcpApiName,
+ parseGitHubToolName,
+ staticGitHubLabelFor,
+} from './labels';
diff --git a/packages/shared-tool-ui/src/Inspector/GitHub/labels.test.ts b/packages/shared-tool-ui/src/Inspector/GitHub/labels.test.ts
new file mode 100644
index 00000000000..20006d457ae
--- /dev/null
+++ b/packages/shared-tool-ui/src/Inspector/GitHub/labels.test.ts
@@ -0,0 +1,31 @@
+import { describe, expect, it } from 'vitest';
+
+import { getGitHubToolSuffix, isGitHubMcpApiName, parseGitHubToolName } from './labels';
+
+describe('GitHub label helpers', () => {
+ it('normalizes MCP and Codex Apps GitHub tool names', () => {
+ expect(getGitHubToolSuffix('mcp__codex_apps__github__github_create_pull_request')).toBe(
+ 'create_pull_request',
+ );
+ expect(getGitHubToolSuffix('github_update_issue')).toBe('update_issue');
+ expect(getGitHubToolSuffix('server_github_get_repository')).toBe('get_repository');
+ expect(getGitHubToolSuffix('_create_branch')).toBe('create_branch');
+ });
+
+ it('detects only MCP names backed by a GitHub server segment', () => {
+ expect(isGitHubMcpApiName('mcp__codex_apps__github__github_create_pull_request')).toBe(true);
+ expect(isGitHubMcpApiName('mcp__linear-server__get_issue')).toBe(false);
+ expect(isGitHubMcpApiName('github_create_pull_request')).toBe(false);
+ });
+
+ it('parses GitHub suffixes into verb and noun labels', () => {
+ expect(parseGitHubToolName('github_create_pull_request')).toEqual({
+ noun: 'pull request',
+ verb: 'create',
+ });
+ expect(parseGitHubToolName('search_repositories')).toEqual({
+ noun: 'repositories',
+ verb: 'search',
+ });
+ });
+});
diff --git a/packages/shared-tool-ui/src/Inspector/GitHub/labels.ts b/packages/shared-tool-ui/src/Inspector/GitHub/labels.ts
new file mode 100644
index 00000000000..fd6d37aafc0
--- /dev/null
+++ b/packages/shared-tool-ui/src/Inspector/GitHub/labels.ts
@@ -0,0 +1,167 @@
+// Pure label utilities for GitHub tool calls. Used by Codex MCP routing and
+// direct GitHub builtin surfaces without pulling React/style modules into tests.
+
+export const GITHUB_TOOL_NAMES = [
+ 'add_comment',
+ 'check_pull_request_mergeability',
+ 'close_issue',
+ 'close_pull_request',
+ 'compare_commits',
+ 'create_branch',
+ 'create_issue',
+ 'create_pull_request',
+ 'delete_branch',
+ 'fork_repository',
+ 'get_branch',
+ 'get_commit',
+ 'get_file',
+ 'get_issue',
+ 'get_pull_request',
+ 'get_repository',
+ 'list_branches',
+ 'list_commits',
+ 'list_issues',
+ 'list_pull_requests',
+ 'list_repositories',
+ 'merge_pull_request',
+ 'reopen_issue',
+ 'reopen_pull_request',
+ 'request_review',
+ 'search_code',
+ 'search_issues',
+ 'search_pull_requests',
+ 'search_repositories',
+ 'update_issue',
+ 'update_pull_request',
+] as const;
+
+const NOUN_OVERRIDES: Record<string, string> = {
+ branch: 'branch',
+ branches: 'branches',
+ code: 'code',
+ commit: 'commit',
+ commits: 'commits',
+ file: 'file',
+ issue: 'issue',
+ issues: 'issues',
+ pull_request: 'pull request',
+ pull_requests: 'pull requests',
+ repositories: 'repositories',
+ repository: 'repository',
+ review: 'review',
+};
+
+export interface ParsedGitHubTool {
+ noun: string;
+ verb:
+ | 'add'
+ | 'check'
+ | 'close'
+ | 'compare'
+ | 'create'
+ | 'delete'
+ | 'fork'
+ | 'get'
+ | 'list'
+ | 'merge'
+ | 'reopen'
+ | 'request'
+ | 'search'
+ | 'update'
+ | 'other';
+}
+
+const isGitHubMcpServerSegment = (segment: string) =>
+ segment
+ .toLowerCase()
+ .split(/[^a-z0-9]+/u)
+ .includes('github');
+
+const toSnakeCase = (value: string) =>
+ value
+ .replaceAll(/([a-z0-9])([A-Z])/g, '$1_$2')
+ .replaceAll(/[-\s]+/g, '_')
+ .toLowerCase();
+
+const stripGitHubToolPrefixes = (value: string): string => {
+ let suffix = toSnakeCase(value.trim());
+ let changed = true;
+
+ while (changed) {
+ changed = false;
+
+ if (suffix.startsWith('server_github_')) {
+ suffix = suffix.slice('server_github_'.length);
+ changed = true;
+ }
+
+ if (suffix.startsWith('github_')) {
+ suffix = suffix.slice('github_'.length);
+ changed = true;
+ }
+
+ while (suffix.startsWith('_')) {
+ suffix = suffix.slice(1);
+ changed = true;
+ }
+ }
+
+ return suffix;
+};
+
+export const getGitHubToolSuffix = (apiName: string): string => {
+ const parts = apiName.split('__');
+ const rawSuffix =
+ parts.length >= 3 && parts[0] === 'mcp' && parts.slice(1, -1).some(isGitHubMcpServerSegment)
+ ? parts.at(-1) || apiName
+ : apiName;
+
+ return stripGitHubToolPrefixes(rawSuffix);
+};
+
+export const isGitHubMcpApiName = (apiName: string): boolean => {
+ const parts = apiName.split('__');
+ return (
+ parts.length >= 3 && parts[0] === 'mcp' && parts.slice(1, -1).some(isGitHubMcpServerSegment)
+ );
+};
+
+export const parseGitHubToolName = (apiName: string): ParsedGitHubTool => {
+ const suffix = getGitHubToolSuffix(apiName);
+ const underscoreIdx = suffix.indexOf('_');
+ if (underscoreIdx <= 0) return { noun: suffix, verb: 'other' };
+
+ const head = suffix.slice(0, underscoreIdx);
+ const tail = suffix.slice(underscoreIdx + 1);
+ const noun = NOUN_OVERRIDES[tail] ?? tail.replaceAll('_', ' ');
+
+ switch (head) {
+ case 'add':
+ case 'check':
+ case 'close':
+ case 'compare':
+ case 'create':
+ case 'delete':
+ case 'fork':
+ case 'get':
+ case 'list':
+ case 'merge':
+ case 'reopen':
+ case 'request':
+ case 'search':
+ case 'update': {
+ return { noun, verb: head };
+ }
+ default: {
+ return { noun: suffix.replaceAll('_', ' '), verb: 'other' };
+ }
+ }
+};
+
+export const capitalize = (s: string) => (s ? s.charAt(0).toUpperCase() + s.slice(1) : s);
+
+export const staticGitHubLabelFor = (parsed: ParsedGitHubTool): string => {
+ const { verb, noun } = parsed;
+ if (verb === 'other') return capitalize(noun);
+ return `${capitalize(verb)} ${noun}`;
+};
diff --git a/packages/shared-tool-ui/src/Inspector/index.ts b/packages/shared-tool-ui/src/Inspector/index.ts
index eebb6cab3ea..2c314f94933 100644
--- a/packages/shared-tool-ui/src/Inspector/index.ts
+++ b/packages/shared-tool-ui/src/Inspector/index.ts
@@ -1,4 +1,5 @@
export { createEditLocalFileInspector } from './EditLocalFile';
+export { GITHUB_TOOL_NAMES, GitHubInspector } from './GitHub';
export { createGlobLocalFilesInspector } from './GlobLocalFiles';
export { createGrepContentInspector } from './GrepContent';
export { LINEAR_TOOL_NAMES, LinearInspector } from './Linear';
diff --git a/packages/shared-tool-ui/src/Render/GitHub/index.tsx b/packages/shared-tool-ui/src/Render/GitHub/index.tsx
new file mode 100644
index 00000000000..7ae663151ec
--- /dev/null
+++ b/packages/shared-tool-ui/src/Render/GitHub/index.tsx
@@ -0,0 +1,310 @@
+'use client';
+
+import type { BuiltinRenderProps } from '@lobechat/types';
+import { fromNow } from '@lobechat/utils/time';
+import { Block, Flexbox, Highlighter, Icon, Markdown, Tag, Text } from '@lobehub/ui';
+import { createStaticStyles } from 'antd-style';
+import { ExternalLink, Link2 } from 'lucide-react';
+import type { ReactNode } from 'react';
+import { memo, useMemo } from 'react';
+import { useTranslation } from 'react-i18next';
+
+import {
+ buildGitHubRenderModel,
+ formatIsoDate,
+ type GitHubEntity,
+ type GitHubField,
+ type GitHubLink,
+} from './utils';
+
+const styles = createStaticStyles(({ css, cssVar }) => ({
+ container: css`
+ overflow: hidden;
+ min-width: 0;
+ `,
+ description: css`
+ overflow: auto;
+
+ max-height: 180px;
+ padding-block: 8px;
+ padding-inline: 10px;
+ border: 1px solid ${cssVar.colorBorderSecondary};
+ border-radius: 6px;
+
+ background: ${cssVar.colorFillQuaternary};
+ `,
+ entityHeader: css`
+ display: flex;
+ gap: 12px;
+ align-items: center;
+ justify-content: space-between;
+
+ min-width: 0;
+ `,
+ headLeft: css`
+ display: flex;
+ gap: 6px;
+ align-items: center;
+ min-width: 0;
+ `,
+ linkRow: css`
+ overflow: hidden;
+ display: flex;
+ gap: 8px;
+ align-items: center;
+
+ min-width: 0;
+ padding-block: 6px;
+ padding-inline: 8px;
+ border-radius: 6px;
+
+ color: ${cssVar.colorText};
+
+ background: ${cssVar.colorFillQuaternary};
+
+ &:hover {
+ color: ${cssVar.colorLink};
+ background: ${cssVar.colorFillTertiary};
+ }
+ `,
+ linkText: css`
+ overflow: hidden;
+ min-width: 0;
+ `,
+ metaItem: css`
+ display: inline-flex;
+ gap: 4px;
+ align-items: baseline;
+
+ min-width: 0;
+
+ font-size: 12px;
+ line-height: 1.5;
+ `,
+ metaLabel: css`
+ flex-shrink: 0;
+ color: ${cssVar.colorTextTertiary};
+ `,
+ metaRow: css`
+ display: flex;
+ flex-wrap: wrap;
+ gap: 4px 16px;
+ align-items: baseline;
+
+ min-width: 0;
+ `,
+ metaValue: css`
+ overflow: hidden;
+
+ min-width: 0;
+
+ color: ${cssVar.colorTextSecondary};
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ `,
+ rawDetails: css`
+ font-size: 12px;
+ color: ${cssVar.colorTextSecondary};
+
+ summary {
+ cursor: pointer;
+ width: fit-content;
+ margin-block-end: 6px;
+ }
+ `,
+ sectionLabel: css`
+ font-size: 12px;
+ color: ${cssVar.colorTextSecondary};
+ `,
+ timeItem: css`
+ flex-shrink: 0;
+ font-size: 12px;
+ color: ${cssVar.colorTextTertiary};
+ white-space: nowrap;
+ `,
+ titleLink: css`
+ display: inline-flex;
+ gap: 4px;
+ align-items: center;
+
+ min-width: 0;
+
+ color: inherit;
+
+ &:hover {
+ color: ${cssVar.colorLink};
+ }
+ `,
+}));
+
+const hasItems = <T,>(items: T[]) => items.length > 0;
+
+const Section = memo<{ children: ReactNode; title: string }>(({ children, title }) => (
+ <Flexbox gap={6}>
+ <Text className={styles.sectionLabel}>{title}</Text>
+ {children}
+ </Flexbox>
+));
+Section.displayName = 'GitHubRenderSection';
+
+const MetaRow = memo<{ fields: GitHubField[] }>(({ fields }) => {
+ if (!hasItems(fields)) return null;
+
+ return (
+ <div className={styles.metaRow}>
+ {fields.map((field) => (
+ <span className={styles.metaItem} key={`${field.key}:${field.value}`}>
+ <span className={styles.metaLabel}>{field.label}</span>
+ <span className={styles.metaValue} title={field.value}>
+ {field.value}
+ </span>
+ </span>
+ ))}
+ </div>
+ );
+});
+MetaRow.displayName = 'GitHubRenderMetaRow';
+
+const LinkList = memo<{ links: GitHubLink[] }>(({ links }) => {
+ if (!hasItems(links)) return null;
+
+ return (
+ <Flexbox gap={4}>
+ {links.map((link) => (
+ <a
+ className={styles.linkRow}
+ href={link.url}
+ key={`${link.title}:${link.url}`}
+ rel={'noreferrer'}
+ target={'_blank'}
+ >
+ <Icon icon={Link2} size={13} />
+ <Text ellipsis className={styles.linkText} title={link.title}>
+ {link.title}
+ </Text>
+ <Icon icon={ExternalLink} size={12} />
+ </a>
+ ))}
+ </Flexbox>
+ );
+});
+LinkList.displayName = 'GitHubRenderLinkList';
+
+const EntityCard = memo<{ entity: GitHubEntity }>(({ entity }) => {
+ const { t } = useTranslation('plugin');
+ const { title, id, url, state, updatedAt, kind } = entity;
+
+ return (
+ <Block gap={8} padding={10} variant={'outlined'} width={'100%'}>
+ <div className={styles.entityHeader}>
+ <div className={styles.headLeft}>
+ <Tag size={'small'}>{kind}</Tag>
+ {title &&
+ (url ? (
+ <a className={styles.titleLink} href={url} rel={'noreferrer'} target={'_blank'}>
+ <Text ellipsis weight={600}>
+ {title}
+ </Text>
+ <Icon icon={ExternalLink} size={12} />
+ </a>
+ ) : (
+ <Text ellipsis weight={600}>
+ {title}
+ </Text>
+ ))}
+ {id && <Tag size={'small'}>{id}</Tag>}
+ {state && (
+ <Tag size={'small'} variant={'outlined'}>
+ {state}
+ </Tag>
+ )}
+ </div>
+ {updatedAt && (
+ <span className={styles.timeItem} title={formatIsoDate(updatedAt)}>
+ {t('builtins.github.render.updatedAt', { time: fromNow(updatedAt) })}
+ </span>
+ )}
+ </div>
+ <MetaRow fields={entity.fields} />
+ {entity.description && (
+ <div className={styles.description}>
+ <Markdown fontSize={13} variant={'chat'}>
+ {entity.description}
+ </Markdown>
+ </div>
+ )}
+ <LinkList links={entity.links} />
+ </Block>
+ );
+});
+EntityCard.displayName = 'GitHubRenderEntityCard';
+
+const GitHubRender = memo<BuiltinRenderProps<Record<string, unknown>, unknown, unknown>>(
+ ({ apiName, args, content, pluginError }) => {
+ const { t } = useTranslation('plugin');
+ const model = useMemo(
+ () => buildGitHubRenderModel({ apiName, args, content, pluginError }),
+ [apiName, args, content, pluginError],
+ );
+ const hasResult =
+ hasItems(model.resultEntities) || Boolean(model.resultText) || Boolean(model.rawResultJson);
+
+ if (!hasResult && !model.errorText) return null;
+
+ return (
+ <Flexbox className={styles.container} gap={12}>
+ {hasItems(model.resultEntities) && (
+ <Flexbox gap={8}>
+ {model.resultEntities.map((entity, index) => (
+ <EntityCard
+ entity={entity}
+ key={`${entity.id || entity.title || 'entity'}:${index}`}
+ />
+ ))}
+ </Flexbox>
+ )}
+ {model.resultText && (
+ <Highlighter
+ wrap
+ language={'text'}
+ showLanguage={false}
+ style={{ maxHeight: 220, overflow: 'auto', paddingInline: 8 }}
+ variant={'filled'}
+ >
+ {model.resultText}
+ </Highlighter>
+ )}
+ {model.rawResultJson && (
+ <details className={styles.rawDetails}>
+ <summary>{t('builtins.github.render.rawResult')}</summary>
+ <Highlighter
+ wrap
+ language={'json'}
+ style={{ maxHeight: 260, overflow: 'auto', paddingInline: 8 }}
+ variant={'filled'}
+ >
+ {model.rawResultJson}
+ </Highlighter>
+ </details>
+ )}
+ {model.errorText && (
+ <Section title={t('builtins.github.render.error')}>
+ <Highlighter
+ wrap
+ language={'text'}
+ showLanguage={false}
+ style={{ maxHeight: 220, overflow: 'auto', paddingInline: 8 }}
+ variant={'filled'}
+ >
+ {model.errorText}
+ </Highlighter>
+ </Section>
+ )}
+ </Flexbox>
+ );
+ },
+);
+
+GitHubRender.displayName = 'GitHubRender';
+
+export default GitHubRender;
diff --git a/packages/shared-tool-ui/src/Render/GitHub/utils.test.ts b/packages/shared-tool-ui/src/Render/GitHub/utils.test.ts
new file mode 100644
index 00000000000..3fe23e140c8
--- /dev/null
+++ b/packages/shared-tool-ui/src/Render/GitHub/utils.test.ts
@@ -0,0 +1,67 @@
+import { describe, expect, it } from 'vitest';
+
+import { buildGitHubRenderModel } from './utils';
+
+describe('buildGitHubRenderModel', () => {
+ it('summarizes a GitHub pull request result without exposing raw JSON first', () => {
+ const model = buildGitHubRenderModel({
+ apiName: 'create_pull_request',
+ args: {
+ base: 'canary',
+ head: 'fix/codex-github-render',
+ repository_full_name: 'lobehub/lobehub',
+ },
+ content: JSON.stringify({
+ body: 'PR body',
+ draft: false,
+ mergeable: true,
+ merged: false,
+ number: 16430,
+ state: 'open',
+ title: 'Render Codex GitHub MCP tool calls',
+ updated_at: '2026-06-29T08:20:00Z',
+ url: 'https://github.com/lobehub/lobehub/pull/16430',
+ }),
+ });
+
+ expect(model.rawResultJson).toBeUndefined();
+ expect(model.resultEntities).toHaveLength(1);
+ expect(model.resultEntities[0]).toMatchObject({
+ description: 'PR body',
+ id: '#16430',
+ kind: 'Pull request',
+ state: 'Open',
+ title: 'Render Codex GitHub MCP tool calls',
+ url: 'https://github.com/lobehub/lobehub/pull/16430',
+ });
+ expect(model.resultEntities[0].fields).toEqual(
+ expect.arrayContaining([
+ { key: 'repository', label: 'Repository', value: 'lobehub/lobehub' },
+ ]),
+ );
+ });
+
+ it('unwraps GitHub list wrappers into entity cards', () => {
+ const model = buildGitHubRenderModel({
+ apiName: 'search_issues',
+ args: { query: 'is:open repo:lobehub/lobehub' },
+ content: JSON.stringify({
+ items: [
+ {
+ number: 10,
+ state: 'open',
+ title: 'First issue',
+ url: 'https://github.com/lobehub/lobehub/issues/10',
+ },
+ ],
+ }),
+ });
+
+ expect(model.resultEntities).toHaveLength(1);
+ expect(model.resultEntities[0]).toMatchObject({
+ id: '#10',
+ kind: 'Issue',
+ title: 'First issue',
+ });
+ });
+});
diff --git a/packages/shared-tool-ui/src/Render/GitHub/utils.ts b/packages/shared-tool-ui/src/Render/GitHub/utils.ts
new file mode 100644
index 00000000000..40dac0d0e63
--- /dev/null
+++ b/packages/shared-tool-ui/src/Render/GitHub/utils.ts
@@ -0,0 +1,411 @@
+import { isRecord } from '@lobechat/utils/object';
+import { safeParseJSON } from '@lobechat/utils/safeParseJSON';
+
+import { parseGitHubToolName, staticGitHubLabelFor } from '../../Inspector/GitHub/labels';
+
+const RESULT_ARRAY_KEYS = [
+ 'items',
+ 'nodes',
+ 'results',
+ 'pullRequests',
+ 'pull_requests',
+ 'issues',
+ 'repositories',
+ 'branches',
+ 'commits',
+ 'comments',
+ 'reviews',
+] as const;
+
+const FIELD_KEYS = [
+ 'repository_full_name',
+ 'repository',
+ 'full_name',
+ 'owner',
+ 'base',
+ 'head',
+ 'base_ref',
+ 'head_ref',
+ 'branch',
+ 'state',
+ 'draft',
+ 'merged',
+ 'mergeable',
+ 'private',
+ 'visibility',
+ 'language',
+ 'additions',
+ 'deletions',
+ 'changed_files',
+ 'comments',
+ 'review_comments',
+] as const;
+
+const DATE_FIELD_KEYS = new Set([
+ 'created_at',
+ 'updated_at',
+ 'closed_at',
+ 'merged_at',
+ 'pushed_at',
+]);
+
+export interface GitHubField {
+ key: string;
+ label: string;
+ value: string;
+}
+
+export interface GitHubLink {
+ title: string;
+ url: string;
+}
+
+export interface GitHubEntity {
+ description?: string;
+ fields: GitHubField[];
+ id?: string;
+ kind: string;
+ links: GitHubLink[];
+ state?: string;
+ title?: string;
+ updatedAt?: string;
+ url?: string;
+}
+
+export interface GitHubRenderModel {
+ actionLabel: string;
+ errorText?: string;
+ rawResultJson?: string;
+ resultEntities: GitHubEntity[];
+ resultText?: string;
+}
+
+const toLabel = (key: string) =>
+ key
+ .replaceAll('_', ' ')
+ .replaceAll(/([A-Z])/g, ' $1')
+ .replace(/^./u, (char) => char.toUpperCase())
+ .trim()
+ .replace('Url', 'URL')
+ .replace('Id', 'ID');
+
+const trimString = (value: unknown): string | undefined => {
+ if (typeof value !== 'string') return;
+
+ const trimmed = value.trim();
+ return trimmed.length > 0 ? trimmed : undefined;
+};
+
+const stringifyUnknown = (value: unknown): string => {
+ if (typeof value === 'string') return value.trim();
+ if (value === undefined || value === null) return '';
+
+ try {
+ return JSON.stringify(value, null, 2);
+ } catch {
+ return String(value);
+ }
+};
+
+const readDisplayString = (value: unknown): string | undefined => {
+ const stringValue = trimString(value);
+ if (stringValue) return stringValue;
+
+ if (typeof value === 'number') return String(value);
+ if (typeof value === 'boolean') return value ? 'Yes' : 'No';
+
+ if (isRecord(value)) {
+ for (const candidate of ['full_name', 'name', 'title', 'login', 'ref', 'id']) {
+ const nested = readDisplayString(value[candidate]);
+ if (nested) return nested;
+ }
+ }
+};
+
+export const formatIsoDate = (value: string): string => {
+ const match = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}(?::\d{2})?)/u.exec(value);
+ return match ? `${match[1]} ${match[2]}` : value;
+};
+
+const pickField = (record: Record<PropertyKey, unknown>, key: string): GitHubField | undefined => {
+ const value = readDisplayString(record[key]);
+ if (!value) return;
+
+ return {
+ key,
+ label: toLabel(key),
+ value: DATE_FIELD_KEYS.has(key) ? formatIsoDate(value) : value,
+ };
+};
+
+const collectFields = (
+ record: Record<PropertyKey, unknown>,
+ keys: readonly string[],
+): GitHubField[] =>
+ keys.map((key) => pickField(record, key)).filter((field): field is GitHubField => Boolean(field));
+
+const getTextFromContentItem = (item: unknown): string => {
+ if (typeof item === 'string') return item;
+ if (!isRecord(item)) return stringifyUnknown(item);
+
+ return trimString(item.text) || trimString(item.content) || stringifyUnknown(item);
+};
+
+const parseJsonString = (value: string): unknown => safeParseJSON(value);
+
+const parseContentText = (value: unknown): unknown => {
+ if (typeof value !== 'string') return value;
+
+ const trimmed = value.trim();
+ if (!trimmed) return undefined;
+
+ return parseJsonString(trimmed) ?? trimmed;
+};
+
+const unwrapResultEnvelope = (value: unknown): unknown => {
+ if (!isRecord(value)) return value;
+
+ if ('Ok' in value) return value.Ok;
+ if ('Err' in value) return value.Err;
+ if ('ok' in value) return value.ok;
+ if ('error' in value && Object.keys(value).length === 1) return value.error;
+
+ return value;
+};
+
+const parseResultContent = (content: unknown): unknown => {
+ const parsed = unwrapResultEnvelope(parseContentText(content));
+
+ if (Array.isArray(parsed)) {
+ const joined = parsed.map(getTextFromContentItem).filter(Boolean).join('\n\n');
+ return parseContentText(joined) ?? parsed;
+ }
+
+ if (isRecord(parsed) && Array.isArray(parsed.content)) {
+ const joined = parsed.content.map(getTextFromContentItem).filter(Boolean).join('\n\n');
+ return parseContentText(joined) ?? parsed;
+ }
+
+ return parsed;
+};
+
+const isWebGithubUrl = (url?: string) =>
+ Boolean(url && /^https?:\/\/github\.com\//iu.test(url.trim()));
+
+const extractUrl = (record: Record<PropertyKey, unknown>) => {
+ const htmlUrl = readDisplayString(record.html_url) || readDisplayString(record.webUrl);
+ if (htmlUrl) return htmlUrl;
+
+ const url = readDisplayString(record.url);
+ return isWebGithubUrl(url) ? url : undefined;
+};
+
+const getGitHubLinks = (value: unknown): GitHubLink[] => {
+ if (!Array.isArray(value)) return [];
+
+ return value
+ .map((item) => {
+ if (!isRecord(item)) return;
+
+ const url = extractUrl(item);
+ if (!url) return;
+
+ return {
+ title: readDisplayString(item.title) || readDisplayString(item.name) || url,
+ url,
+ };
+ })
+ .filter((link): link is GitHubLink => Boolean(link));
+};
+
+const getRepoName = (record: Record<PropertyKey, unknown>, args: unknown): string | undefined => {
+ const fromRecord =
+ readDisplayString(record.repository_full_name) ||
+ readDisplayString(record.full_name) ||
+ readDisplayString(record.repository);
+ if (fromRecord) return fromRecord;
+
+ if (!isRecord(args)) return;
+
+ const fromArgs =
+ readDisplayString(args.repository_full_name) ||
+ readDisplayString(args.full_name) ||
+ readDisplayString(args.repository) ||
+ readDisplayString(args.repo);
+ if (fromArgs) return fromArgs;
+
+ const owner = readDisplayString(args.owner);
+ const name = readDisplayString(args.name);
+ return owner && name ? `${owner}/${name}` : undefined;
+};
+
+const inferKind = (
+ record: Record<PropertyKey, unknown>,
+ apiName: string | undefined,
+ url?: string,
+): string => {
+ const api = apiName || '';
+ if (
+ api.includes('pull_request') ||
+ url?.includes('/pull/') ||
+ 'mergeable' in record ||
+ 'draft' in record
+ ) {
+ return 'Pull request';
+ }
+
+ if (api.includes('issue') || url?.includes('/issues/')) return 'Issue';
+ if (api.includes('repository') || 'full_name' in record) return 'Repository';
+ if (api.includes('branch') || 'ref' in record) return 'Branch';
+ if (api.includes('commit') || 'sha' in record) return 'Commit';
+ if (api.includes('comment')) return 'Comment';
+
+ return 'Result';
+};
+
+const pickState = (record: Record<PropertyKey, unknown>): string | undefined => {
+ if (record.merged === true) return 'Merged';
+ if (record.draft === true) return 'Draft';
+
+ const state = readDisplayString(record.state) || readDisplayString(record.status);
+ return state ? state.replace(/^./u, (char) => char.toUpperCase()) : undefined;
+};
+
+const pickId = (record: Record<PropertyKey, unknown>): string | undefined => {
+ const number = readDisplayString(record.number);
+ if (number) return `#${number}`;
+
+ const sha = readDisplayString(record.sha);
+ if (sha) return sha.slice(0, 12);
+
+ return readDisplayString(record.id);
+};
+
+const buildEntity = (
+ record: Record<PropertyKey, unknown>,
+ args: unknown,
+ apiName?: string,
+): GitHubEntity | undefined => {
+ const url = extractUrl(record);
+ const kind = inferKind(record, apiName, url);
+ const repo = getRepoName(record, args);
+ const title =
+ readDisplayString(record.title) ||
+ readDisplayString(record.name) ||
+ readDisplayString(record.full_name) ||
+ readDisplayString(record.path) ||
+ readDisplayString(record.message);
+ const id = pickId(record);
+ const state = pickState(record);
+ const description =
+ readDisplayString(record.body) ||
+ readDisplayString(record.description) ||
+ readDisplayString(record.content);
+ const fields = [
+ ...(repo ? [{ key: 'repository', label: 'Repository', value: repo }] : []),
+ ...collectFields(record, FIELD_KEYS).filter(
+ (field) =>
+ field.value !== repo &&
+ !(
+ (field.key === 'state' || field.key === 'status') &&
+ field.value.toLowerCase() === state?.toLowerCase()
+ ),
+ ),
+ ];
+ const links = getGitHubLinks(record.links);
+ const updatedAt = readDisplayString(record.updated_at) || readDisplayString(record.updatedAt);
+
+ if (
+ !id &&
+ !title &&
+ !url &&
+ !state &&
+ !description &&
+ !updatedAt &&
+ fields.length === 0 &&
+ links.length === 0
+ )
+ return;
+
+ return {
+ description,
+ fields,
+ id,
+ kind,
+ links,
+ state,
+ title,
+ updatedAt,
+ url,
+ };
+};
+
+const ENTITY_IDENTITY_KEYS = [
+ 'id',
+ 'number',
+ 'title',
+ 'name',
+ 'full_name',
+ 'sha',
+ 'html_url',
+ 'url',
+] as const;
+
+const looksLikeEntity = (record: Record<PropertyKey, unknown>): boolean =>
+ ENTITY_IDENTITY_KEYS.some((key) => Boolean(readDisplayString(record[key])));
+
+const extractResultRecords = (value: unknown): Record<PropertyKey, unknown>[] => {
+ if (Array.isArray(value)) return value.filter(isRecord);
+ if (!isRecord(value)) return [];
+
+ if (!looksLikeEntity(value)) {
+ for (const key of RESULT_ARRAY_KEYS) {
+ const nested = value[key];
+ if (Array.isArray(nested)) return nested.filter(isRecord);
+ }
+ }
+
+ return [value];
+};
+
+const getErrorText = (error: unknown): string | undefined => {
+ if (!error) return;
+ if (typeof error === 'string') return error.trim() || undefined;
+ if (isRecord(error)) {
+ return (
+ readDisplayString(error.message) || readDisplayString(error.error) || stringifyUnknown(error)
+ );
+ }
+
+ return stringifyUnknown(error);
+};
+
+export const buildGitHubRenderModel = ({
+ apiName,
+ args,
+ content,
+ pluginError,
+}: {
+ apiName?: string;
+ args: unknown;
+ content: unknown;
+ pluginError?: unknown;
+}): GitHubRenderModel => {
+ const result = parseResultContent(content);
+ const resultEntities = extractResultRecords(result)
+ .map((record) => buildEntity(record, args, apiName))
+ .filter((entity): entity is GitHubEntity => Boolean(entity));
+ const resultText = typeof result === 'string' ? result : undefined;
+ const rawResultJson =
+ result !== undefined && typeof result !== 'string' && resultEntities.length === 0
+ ? stringifyUnknown(result)
+ : undefined;
+
+ return {
+ actionLabel: staticGitHubLabelFor(parseGitHubToolName(apiName || '')),
+ errorText: getErrorText(pluginError),
+ rawResultJson,
+ resultEntities,
+ resultText,
+ };
+};
diff --git a/packages/shared-tool-ui/src/Render/index.ts b/packages/shared-tool-ui/src/Render/index.ts
index 61914d29214..6f58161384f 100644
--- a/packages/shared-tool-ui/src/Render/index.ts
+++ b/packages/shared-tool-ui/src/Render/index.ts
@@ -1,2 +1,3 @@
+export { default as GitHubRender } from './GitHub';
export { default as LinearRender } from './Linear';
export { default as RunCommandRender } from './RunCommand';
diff --git a/src/features/DevPanel/RenderGallery/fixtures/codex.ts b/src/features/DevPanel/RenderGallery/fixtures/codex.ts
index 04dd94bcaa0..24a7eef11c8 100644
--- a/src/features/DevPanel/RenderGallery/fixtures/codex.ts
+++ b/src/features/DevPanel/RenderGallery/fixtures/codex.ts
@@ -36,6 +36,31 @@ const linearIssueResult = {
url: 'https://linear.app/lobehub/issue/TEST-0000',
};
+const githubPullRequestResult = {
+ base: 'canary',
+ body: [
+ '#### Description of Change',
+ '',
+ '- Add a GitHub MCP render for Codex Apps tool calls.',
+ '- Replace the raw JSON block with a PR summary card.',
+ '',
+ '#### How to Test',
+ '',
+ '- Open the Codex render gallery.',
+ '- Check the GitHub create pull request fixture.',
+ ].join('\n'),
+ draft: false,
+ head: 'fix/codex-github-render',
+ mergeable: true,
+ merged: false,
+ number: 16430,
+ repository_full_name: 'lobehub/lobehub',
+ state: 'open',
+ title: 'Render Codex GitHub MCP tool calls',
+ updated_at: '2026-06-29T08:20:00Z',
+ url: 'https://github.com/lobehub/lobehub/pull/16430',
+};
+
export default defineFixtures({
identifier: 'codex',
meta: {
@@ -179,6 +204,35 @@ export default defineFixtures({
tool: 'linear_save_issue',
},
},
+ {
+ args: {
+ arguments: {
+ base: 'canary',
+ head: 'fix/codex-github-render',
+ repository_full_name: 'lobehub/lobehub',
+ title: 'Render Codex GitHub MCP tool calls',
+ },
+ server: 'mcp__codex_apps__github',
+ tool: 'github_create_pull_request',
+ },
+ content: JSON.stringify(githubPullRequestResult),
+ label: 'GitHub create pull request',
+ pluginState: {
+ arguments: {
+ base: 'canary',
+ head: 'fix/codex-github-render',
+ repository_full_name: 'lobehub/lobehub',
+ title: 'Render Codex GitHub MCP tool calls',
+ },
+ result: {
+ content: [{ text: JSON.stringify(githubPullRequestResult), type: 'text' }],
+ isError: false,
+ },
+ server: 'mcp__codex_apps__github',
+ status: 'completed',
+ tool: 'github_create_pull_request',
+ },
+ },
]),
todo_list: single({
args: {
diff --git a/src/features/DevPanel/RenderGallery/fixtures/github.ts b/src/features/DevPanel/RenderGallery/fixtures/github.ts
index 9fd93fa70b5..a190424a8b5 100644
--- a/src/features/DevPanel/RenderGallery/fixtures/github.ts
+++ b/src/features/DevPanel/RenderGallery/fixtures/github.ts
@@ -5,6 +5,28 @@ import { defineFixtures, single } from './_helpers';
export default defineFixtures({
identifier: 'github',
fixtures: {
+ create_pull_request: single({
+ args: {
+ base: 'canary',
+ head: 'fix/codex-github-render',
+ repository_full_name: 'lobehub/lobehub',
+ title: 'Render Codex GitHub MCP tool calls',
+ },
+ content: JSON.stringify({
+ base: 'canary',
+ body: 'Render Codex GitHub MCP tool calls with a dedicated summary card.',
+ draft: false,
+ head: 'fix/codex-github-render',
+ mergeable: true,
+ merged: false,
+ number: 16430,
+ repository_full_name: 'lobehub/lobehub',
+ state: 'open',
+ title: 'Render Codex GitHub MCP tool calls',
+ updated_at: '2026-06-29T08:20:00Z',
+ url: 'https://github.com/lobehub/lobehub/pull/16430',
+ }),
+ }),
run_command: single({
args: {
command: 'gh api /repos/lobehub/lobe-chat/issues?state=open',