Navigate to the server directory and execute:
uv run uvicorn mcp_server:app --host 0.0.0.0 (for availablility to any client)
uv run uvicorn mcp_server:app --host <ipaddr> (for availability only to a certain ip)
Navigate to the client directory and execute:
uv run groq_client_test.py <server_addr>
Note that the server address should include the endpoint /mcp.
For example:
uv run groq_client_test.py http://123.109.82.44:8000/mcp
Copy client/groq_client.ts into your frontend project (in most cases, a /utils directory). Then include it with:
import type { GroqInputSchema, GroqOutputSchema } from 'utils/groq_client';
import { GroqMCPClient } from 'utils/groq_client';
Create the client and start the connection like:
const groq_mcp_client = new GroqMCPClient();
await groq_mcp_client.connect_to_remote_server('http://127.0.0.1:8000/mcp');
- Note that
connect_to_remote_serverreturns aboolrepresenting if the connection was successful.
Query like:
output: GroqOutputSchema = await groq_mcp_client.process_input([
{
role: 'system',
content: 'You are a helper designed to manage homeless patient info, opportunities for patients, and grant form information.
"Current fields" are data that have no or insignificant change over time.
"History fields" are data that have meaningful change over time.'
},
{
role: 'user',
content: 'Add a new patient named Harry.'
}
] as GroqInputSchema)
Disconnect like:
await groq_mcp_client.disconnect_from_remote_server();
Definition:
export type GroqOutputSchema = {
content: string
ui: 'no change' | 'patient' | 'opportunity' | 'grant'
name: string
}
content gives the result of the Groq LLM, along with any tool calls its made. Just display this back to the user in chat logs.
ui signals a switch in the UI. Database calls will be up to the rest of the frontend. The options are self-explanatory:
no change- no change to the UI.patient- displays all data for a certain patient.opportunity- displays all data for a certain opportunity.grant- displays all data for a certain grant.