Summary
The FastMcpStarter currently does not expose the instructions parameter, which is a standard field in the MCP (Model Context Protocol) specification. This prevents servers from providing usage instructions to clients, limiting the LLM's ability to understand available tools and resources.
Background
According to the MCP specification, instructions is an optional field in the InitializeResult that describes how to use the server and its features. This information can be used by clients to improve the LLM's understanding of available tools, resources, etc., and is typically added to the system prompt.
From the MCP SDK types:
/**
* Instructions describing how to use the server and its features.
*
* This can be used by clients to improve the LLM's understanding of available tools, resources, etc.
* It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.
*/
instructions: z.ZodOptional<z.ZodString>;
Current Issue
In FastMcpStarter.ts, the FastMCP server is created without the instructions parameter:
const server = new FastMCP({
name: opts.serviceId || 'nuwa-mcp-server',
version: '1.0.0',
// Missing: instructions parameter
});
Similarly, FastMCPSession is created without instructions:
const session = new FastMCPSession({
name: opts.serviceId || 'nuwa-mcp-server',
version: '1.0.0',
// Missing: instructions parameter
// ... other config
});
How Clients Access Instructions
MCP clients access instructions through the standard initialization handshake:
- Client calls
connect() method (returns Promise<void>)
- After successful connection, client calls
getInstructions() to retrieve server instructions
- Instructions are automatically included in the
InitializeResult during the MCP handshake
// Client usage example
const client = new McpClient({ name: 'my-client', version: '1.0.0' });
await client.connect(transport);
const instructions = client.getInstructions(); // Gets instructions from server
Proposed Solution
1. Add instructions option to FastMcpServerOptions
export interface FastMcpServerOptions extends McpPaymentKitOptions {
/** Instructions describing how to use the server and its features */
instructions?: string;
port?: number;
endpoint?: `/${string}`;
register?: (registrar: PaymentMcpToolRegistrar) => void;
wellKnown?: {
enabled?: boolean;
path?: `/${string}`;
};
}
2. Pass instructions to FastMCP constructor
const server = new FastMCP({
name: opts.serviceId || 'nuwa-mcp-server',
version: '1.0.0',
instructions: opts.instructions, // Add this line
});
3. Pass instructions to FastMCPSession constructor
const session = new FastMCPSession({
name: opts.serviceId || 'nuwa-mcp-server',
version: '1.0.0',
instructions: opts.instructions, // Add this line
// ... other config
});
4. Update helper functions
Both createFastMcpServer and createFastMcpServerFromEnv should accept and forward the instructions parameter.
Example Usage
After implementation, developers could use it like this:
const server = await createFastMcpServerFromEnv(env, {
serviceId: "my-service",
instructions: "This server provides weather data and location services. Use get_weather for current conditions and search_locations to find places.",
port: 8080,
// ... other options
});
Benefits
- Improved LLM Understanding: Instructions help LLMs better understand how to use the server's tools and resources
- Better User Experience: More context leads to more accurate tool usage and better results
- MCP Compliance: Follows the standard MCP specification for server metadata
- Backward Compatibility: Adding optional instructions parameter doesn't break existing code
Files to Modify
nuwa-kit/typescript/packages/payment-kit/src/transport/mcp/FastMcpStarter.ts
- Add
instructions? to FastMcpServerOptions interface
- Pass instructions to FastMCP constructor
- Pass instructions to FastMCPSession constructor
- Update function signatures as needed
Acceptance Criteria
Priority
Medium - This is a standard MCP feature that improves the developer experience and LLM interaction quality, but doesn't break existing functionality.
Summary
The
FastMcpStartercurrently does not expose theinstructionsparameter, which is a standard field in the MCP (Model Context Protocol) specification. This prevents servers from providing usage instructions to clients, limiting the LLM's ability to understand available tools and resources.Background
According to the MCP specification,
instructionsis an optional field in theInitializeResultthat describes how to use the server and its features. This information can be used by clients to improve the LLM's understanding of available tools, resources, etc., and is typically added to the system prompt.From the MCP SDK types:
Current Issue
In
FastMcpStarter.ts, the FastMCP server is created without theinstructionsparameter:Similarly,
FastMCPSessionis created without instructions:How Clients Access Instructions
MCP clients access instructions through the standard initialization handshake:
connect()method (returnsPromise<void>)getInstructions()to retrieve server instructionsInitializeResultduring the MCP handshakeProposed Solution
1. Add instructions option to FastMcpServerOptions
2. Pass instructions to FastMCP constructor
3. Pass instructions to FastMCPSession constructor
4. Update helper functions
Both
createFastMcpServerandcreateFastMcpServerFromEnvshould accept and forward the instructions parameter.Example Usage
After implementation, developers could use it like this:
Benefits
Files to Modify
nuwa-kit/typescript/packages/payment-kit/src/transport/mcp/FastMcpStarter.tsinstructions?toFastMcpServerOptionsinterfaceAcceptance Criteria
FastMcpServerOptionsinterface includes optionalinstructionsparameterFastMCPandFastMCPSessionconstructorscreateFastMcpServerandcreateFastMcpServerFromEnvaccept instructions parametergetInstructions()methodPriority
Medium - This is a standard MCP feature that improves the developer experience and LLM interaction quality, but doesn't break existing functionality.