MCP Apps Kit - v0.5.0
    Preparing search index...

    Type Alias MiddlewareWithResult<TResult>

    MiddlewareWithResult: (
        context: MiddlewareContext,
        next: () => Promise<TResult>,
    ) => Promise<TResult>

    Middleware function with result passing

    Allows middleware to inspect and transform results from downstream handlers. The generic type TResult represents the result type that flows through the chain.

    Type Parameters

    • TResult = unknown

      The type of result returned by the handler and middleware chain

    Type Declaration

    const logResult: MiddlewareWithResult<{ data: string }> = async (context, next) => {
    const result = await next();
    console.log("Result:", result.data);
    return result;
    };
    const addTimestamp: MiddlewareWithResult<ToolResult> = async (context, next) => {
    const result = await next();
    return {
    ...result,
    _meta: { ...result._meta, timestamp: Date.now() }
    };
    };