@@ -113,11 +113,15 @@ export default function createServer(
113113 config : z . infer < typeof configSchema >
114114) {
115115 const apiToken = config . mineruApiKey || process . env . MINERU_API_KEY || "" ;
116- if ( ! apiToken ) {
117- throw new Error (
118- "MinerU API Key is required. Provide it via configSchema or set MINERU_API_KEY environment variable."
119- ) ;
120- }
116+
117+ const requireApiKey = ( ) => {
118+ if ( ! apiToken || apiToken === SANDBOX_PLACEHOLDER_KEY ) {
119+ throw new Error (
120+ "MinerU API Key is required. Please configure your API key in Smithery/Cursor settings. " +
121+ "Get your key from https://mineru.net/apiManage/token"
122+ ) ;
123+ }
124+ } ;
121125
122126 const server = new McpServer ( {
123127 name : "mineru-markdown-converter" ,
@@ -208,6 +212,7 @@ export default function createServer(
208212 . describe ( "Enable table recognition" ) ,
209213 } ,
210214 async ( { url, model_version, is_ocr, enable_formula, enable_table } ) => {
215+ requireApiKey ( ) ;
211216 const ext = guessExtFromUrl ( url ) ;
212217 const params = autoConfigureParams ( ext , model_version , is_ocr ) ;
213218
@@ -242,6 +247,7 @@ export default function createServer(
242247 . describe ( "Batch ID returned from create_parse_task (file upload)" ) ,
243248 } ,
244249 async ( { task_id, batch_id } ) => {
250+ requireApiKey ( ) ;
245251 if ( ! task_id && ! batch_id ) {
246252 return {
247253 content : [
@@ -294,6 +300,7 @@ export default function createServer(
294300 max_wait_seconds : number ,
295301 poll_interval : number
296302 ) {
303+ requireApiKey ( ) ;
297304 const ext = guessExtFromUrl ( url ) ;
298305 const params = autoConfigureParams ( ext , model_version ) ;
299306
@@ -450,10 +457,14 @@ export default function createServer(
450457 return server ;
451458}
452459
460+ /** Placeholder key for sandbox mode — connection works, tools return friendly error */
461+ export const SANDBOX_PLACEHOLDER_KEY = "sandbox-placeholder-key" ;
462+
453463/**
454- * Sandbox server for Smithery scanning.
455- * Uses a dummy key so Smithery can discover tools without real credentials.
464+ * Sandbox server for Smithery scanning and connection handshake.
465+ * Uses a dummy key so Smithery can discover tools and connect without real credentials.
466+ * Tool calls return a friendly error asking the user to configure their API key.
456467 */
457468export function createSandboxServer ( ) {
458- return createServer ( { mineruApiKey : "sandbox-placeholder-key" } ) ;
469+ return createServer ( { mineruApiKey : SANDBOX_PLACEHOLDER_KEY } ) ;
459470}
0 commit comments