MCPcopy Create free account
hub / github.com/CopilotKit/aimock / startFromConfig

Function startFromConfig

src/config-loader.ts:112–312  ·  view source on GitHub ↗
(
  config: AimockConfig,
  overrides?: { port?: number; host?: string },
)

Source from the content-addressed store, hash-verified

110}
111
112export async function startFromConfig(
113 config: AimockConfig,
114 overrides?: { port?: number; host?: string },
115): Promise<{ llmock: LLMock; url: string }> {
116 const logger = new Logger("info");
117
118 // Load fixtures if specified
119 const llmock = new LLMock({
120 port: overrides?.port ?? config.port ?? 0,
121 host: overrides?.host ?? config.host ?? "127.0.0.1",
122 chaos: config.llm?.chaos,
123 record: config.llm?.record,
124 metrics: config.metrics,
125 strict: config.strict,
126 });
127
128 if (config.llm?.fixtures) {
129 const fixturePath = path.resolve(config.llm.fixtures);
130 const stat = fs.statSync(fixturePath);
131 if (stat.isDirectory()) {
132 llmock.loadFixtureDir(fixturePath);
133 } else {
134 llmock.loadFixtureFile(fixturePath);
135 }
136 }
137
138 // MCP
139 if (config.mcp) {
140 const mcpConfig = config.mcp;
141 const mcp = new MCPMock({
142 serverInfo: mcpConfig.serverInfo,
143 });
144
145 if (mcpConfig.tools) {
146 for (const tool of mcpConfig.tools) {
147 const { result, ...def } = tool;
148 mcp.addTool(def);
149 if (result !== undefined) {
150 mcp.onToolCall(def.name, () => result);
151 }
152 }
153 }
154
155 if (mcpConfig.resources) {
156 for (const res of mcpConfig.resources) {
157 mcp.addResource(
158 { uri: res.uri, name: res.name, mimeType: res.mimeType, description: res.description },
159 res.text !== undefined || res.blob !== undefined
160 ? { text: res.text, blob: res.blob, mimeType: res.mimeType }
161 : undefined,
162 );
163 }
164 }
165
166 if (mcpConfig.prompts) {
167 for (const prompt of mcpConfig.prompts) {
168 const { result, ...def } = prompt;
169 if (result) {

Callers 2

Calls 15

loadFixtureDirMethod · 0.95
loadFixtureFileMethod · 0.95
addToolMethod · 0.95
onToolCallMethod · 0.95
addResourceMethod · 0.95
addPromptMethod · 0.95
mountMethod · 0.95
infoMethod · 0.95
registerAgentMethod · 0.95
onMessageMethod · 0.95
onTaskMethod · 0.95
onStreamingTaskMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…