Skip to main content
Glama
context.ts1.82 kB
/** * 上下文管理命令 */ import { createClient, createContextManager, ClientOptions } from '../utils/client.js'; import { success, error, outputDetails } from '../utils/output.js'; /** * 获取当前上下文 */ export async function contextGet(options: ClientOptions) { try { const client = await createClient(options); const contextManager = await createContextManager(client, options); const context = contextManager.getContext(); outputDetails({ owner: context.owner || '(未设置)', repo: context.repo || '(未设置)', org: context.org || '(未设置)', project: context.project || '(未设置)', }, options); } catch (err: any) { error(`获取上下文失败: ${err.message}`); process.exit(1); } } /** * 设置默认上下文 */ export async function contextSet(options: ClientOptions & { owner?: string; repo?: string; org?: string; project?: number; }) { try { const client = await createClient(options); const contextManager = await createContextManager(client, options); const newContext: any = {}; if (options.owner) newContext.owner = options.owner; if (options.repo) newContext.repo = options.repo; if (options.org) newContext.org = options.org; if (options.project) newContext.project = options.project; contextManager.setContext(newContext); success('上下文已更新', options); // 显示当前上下文 const context = contextManager.getContext(); outputDetails({ owner: context.owner || '(未设置)', repo: context.repo || '(未设置)', org: context.org || '(未设置)', project: context.project || '(未设置)', }, options); } catch (err: any) { error(`设置上下文失败: ${err.message}`); process.exit(1); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/SupenBysz/gitea-mcp-tool'

If you have feedback or need assistance with the MCP directory API, please join our Discord server