MCP Integration/GPT-4 Setup
GPT-4 Setup
Use MPPFinance with OpenAI function calling via the MCP adapter.
Install
terminal
npm install mppfinance openaiIntegration
gpt4.ts
import OpenAI from 'openai'
import { createMCPClient } from 'mppfinance/mcp'
const openai = new OpenAI()
const mcp = await createMCPClient({ agentId: process.env.MPPFINANCE_AGENT_ID! })
const tools = await mcp.listTools()
const response = await openai.chat.completions.create({
model: 'gpt-4o',
tools: tools.map(t => t.openaiSchema),
messages: [{ role: 'user', content: 'Issue a $20 card for aws.com' }],
})
// Handle tool calls
for (const choice of response.choices) {
if (choice.message.tool_calls) {
for (const call of choice.message.tool_calls) {
const result = await mcp.callTool(call.function.name, JSON.parse(call.function.arguments))
console.log(result)
}
}
}