Okay, our MCP setup is running and I'm going to say,
give me the latest issues on the Matt Pocock TS reset repo
And beautifully, it returns the latest issues. Oh my gosh. We can see in the network tab that it called the tool of list issues just here. Then the tool output became available and then it turned that into some text.
Inside our post request we can see I'm using createMCPClient, passing in a transport of new StdioMCPTransport and then passing in the env of GITHUB_PERSONAL_ACCESS_TOKEN.
The args we're using here is we're using docker run -i --rm -e GITHUB_PERSONAL_ACCESS_TOKEN ghcr.io/github/github-mcp-server. And so you could use this to run any arbitrary command. There are many MCP servers out there that use NPX. For instance, they're just a set of JavaScript files deployed to NPM that you can then use with NPX.
Of course, you wanna check out the code for the MCP servers you're using, you don't just wanna execute arbitrary code on your system. Since this one comes from GitHub themselves, you can be pretty sure it's gonna be okay.
Further down, we then take those tools and call mcpClient.tools(), passing in the tools into streamText.
Finally, in the onFinish callback below, we call mcpClient.close() to close the client.
Now, using MCP servers in your systems effectively is a pretty deep topic. And to be honest, it's a topic of active research right now. But this is a cool setup if you want to just quickly plug in an MCP server into a system, especially one that you're working with locally.
Nice work and I will see you in the next one.
const mcpClient = await createMCPClient({transport: new StdioMCPTransport({command: "docker",args: ["run","-i","--rm","-e","GITHUB_PERSONAL_ACCESS_TOKEN","ghcr.io/github/github-mcp-server",],env: {GITHUB_PERSONAL_ACCESS_TOKEN: process.env.GITHUB_PERSONAL_ACCESS_TOKEN!,},}),})
const result = streamText({model: google("gemini-2.5-flash"),messages: convertToModelMessages(messages),system: `You are a helpful assistant that can use the GitHub API to interact with the user's GitHub account.`,tools: await mcpClient.tools(),stopWhen: [stepCountIs(10)],})
return result.toUIMessageStreamResponse({onFinish: async () => {await mcpClient.close()},})