# Directory Structure
```
├── build
│ ├── cache.js
│ ├── index.js
│ ├── tool-chain.js
│ └── types.js
├── config-example.json
├── node_modules
│ ├── .bin
│ │ ├── tsc
│ │ └── tsserver
│ ├── .package-lock.json
│ ├── @modelcontextprotocol
│ │ └── sdk
│ │ ├── dist
│ │ │ ├── cli.d.ts
│ │ │ ├── cli.d.ts.map
│ │ │ ├── cli.js
│ │ │ ├── cli.js.map
│ │ │ ├── client
│ │ │ │ ├── index.d.ts
│ │ │ │ ├── index.d.ts.map
│ │ │ │ ├── index.js
│ │ │ │ ├── index.js.map
│ │ │ │ ├── index.test.d.ts
│ │ │ │ ├── index.test.d.ts.map
│ │ │ │ ├── index.test.js
│ │ │ │ ├── index.test.js.map
│ │ │ │ ├── sse.d.ts
│ │ │ │ ├── sse.d.ts.map
│ │ │ │ ├── sse.js
│ │ │ │ ├── sse.js.map
│ │ │ │ ├── stdio.d.ts
│ │ │ │ ├── stdio.d.ts.map
│ │ │ │ ├── stdio.js
│ │ │ │ ├── stdio.js.map
│ │ │ │ ├── stdio.test.d.ts
│ │ │ │ ├── stdio.test.d.ts.map
│ │ │ │ ├── stdio.test.js
│ │ │ │ ├── stdio.test.js.map
│ │ │ │ ├── websocket.d.ts
│ │ │ │ ├── websocket.d.ts.map
│ │ │ │ ├── websocket.js
│ │ │ │ └── websocket.js.map
│ │ │ ├── inMemory.d.ts
│ │ │ ├── inMemory.d.ts.map
│ │ │ ├── inMemory.js
│ │ │ ├── inMemory.js.map
│ │ │ ├── inMemory.test.d.ts
│ │ │ ├── inMemory.test.d.ts.map
│ │ │ ├── inMemory.test.js
│ │ │ ├── inMemory.test.js.map
│ │ │ ├── server
│ │ │ │ ├── index.d.ts
│ │ │ │ ├── index.d.ts.map
│ │ │ │ ├── index.js
│ │ │ │ ├── index.js.map
│ │ │ │ ├── index.test.d.ts
│ │ │ │ ├── index.test.d.ts.map
│ │ │ │ ├── index.test.js
│ │ │ │ ├── index.test.js.map
│ │ │ │ ├── sse.d.ts
│ │ │ │ ├── sse.d.ts.map
│ │ │ │ ├── sse.js
│ │ │ │ ├── sse.js.map
│ │ │ │ ├── stdio.d.ts
│ │ │ │ ├── stdio.d.ts.map
│ │ │ │ ├── stdio.js
│ │ │ │ ├── stdio.js.map
│ │ │ │ ├── stdio.test.d.ts
│ │ │ │ ├── stdio.test.d.ts.map
│ │ │ │ ├── stdio.test.js
│ │ │ │ └── stdio.test.js.map
│ │ │ ├── shared
│ │ │ │ ├── protocol.d.ts
│ │ │ │ ├── protocol.d.ts.map
│ │ │ │ ├── protocol.js
│ │ │ │ ├── protocol.js.map
│ │ │ │ ├── stdio.d.ts
│ │ │ │ ├── stdio.d.ts.map
│ │ │ │ ├── stdio.js
│ │ │ │ ├── stdio.js.map
│ │ │ │ ├── stdio.test.d.ts
│ │ │ │ ├── stdio.test.d.ts.map
│ │ │ │ ├── stdio.test.js
│ │ │ │ ├── stdio.test.js.map
│ │ │ │ ├── transport.d.ts
│ │ │ │ ├── transport.d.ts.map
│ │ │ │ ├── transport.js
│ │ │ │ └── transport.js.map
│ │ │ ├── types.d.ts
│ │ │ ├── types.d.ts.map
│ │ │ ├── types.js
│ │ │ └── types.js.map
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ ├── @types
│ │ └── node
│ │ ├── assert
│ │ │ └── strict.d.ts
│ │ ├── assert.d.ts
│ │ ├── async_hooks.d.ts
│ │ ├── buffer.buffer.d.ts
│ │ ├── buffer.d.ts
│ │ ├── child_process.d.ts
│ │ ├── cluster.d.ts
│ │ ├── compatibility
│ │ │ ├── disposable.d.ts
│ │ │ ├── index.d.ts
│ │ │ ├── indexable.d.ts
│ │ │ └── iterators.d.ts
│ │ ├── console.d.ts
│ │ ├── constants.d.ts
│ │ ├── crypto.d.ts
│ │ ├── dgram.d.ts
│ │ ├── diagnostics_channel.d.ts
│ │ ├── dns
│ │ │ └── promises.d.ts
│ │ ├── dns.d.ts
│ │ ├── dom-events.d.ts
│ │ ├── domain.d.ts
│ │ ├── events.d.ts
│ │ ├── fs
│ │ │ └── promises.d.ts
│ │ ├── fs.d.ts
│ │ ├── globals.d.ts
│ │ ├── globals.typedarray.d.ts
│ │ ├── http.d.ts
│ │ ├── http2.d.ts
│ │ ├── https.d.ts
│ │ ├── index.d.ts
│ │ ├── inspector.d.ts
│ │ ├── LICENSE
│ │ ├── module.d.ts
│ │ ├── net.d.ts
│ │ ├── os.d.ts
│ │ ├── package.json
│ │ ├── path.d.ts
│ │ ├── perf_hooks.d.ts
│ │ ├── process.d.ts
│ │ ├── punycode.d.ts
│ │ ├── querystring.d.ts
│ │ ├── readline
│ │ │ └── promises.d.ts
│ │ ├── readline.d.ts
│ │ ├── README.md
│ │ ├── repl.d.ts
│ │ ├── sea.d.ts
│ │ ├── stream
│ │ │ ├── consumers.d.ts
│ │ │ ├── promises.d.ts
│ │ │ └── web.d.ts
│ │ ├── stream.d.ts
│ │ ├── string_decoder.d.ts
│ │ ├── test.d.ts
│ │ ├── timers
│ │ │ └── promises.d.ts
│ │ ├── timers.d.ts
│ │ ├── tls.d.ts
│ │ ├── trace_events.d.ts
│ │ ├── ts5.6
│ │ │ ├── buffer.buffer.d.ts
│ │ │ ├── globals.typedarray.d.ts
│ │ │ └── index.d.ts
│ │ ├── tty.d.ts
│ │ ├── url.d.ts
│ │ ├── util.d.ts
│ │ ├── v8.d.ts
│ │ ├── vm.d.ts
│ │ ├── wasi.d.ts
│ │ ├── worker_threads.d.ts
│ │ └── zlib.d.ts
│ ├── asynckit
│ │ ├── bench.js
│ │ ├── index.js
│ │ ├── lib
│ │ │ ├── abort.js
│ │ │ ├── async.js
│ │ │ ├── defer.js
│ │ │ ├── iterate.js
│ │ │ ├── readable_asynckit.js
│ │ │ ├── readable_parallel.js
│ │ │ ├── readable_serial_ordered.js
│ │ │ ├── readable_serial.js
│ │ │ ├── state.js
│ │ │ ├── streamify.js
│ │ │ └── terminator.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ ├── parallel.js
│ │ ├── README.md
│ │ ├── serial.js
│ │ ├── serialOrdered.js
│ │ └── stream.js
│ ├── axios
│ │ ├── CHANGELOG.md
│ │ ├── dist
│ │ │ ├── axios.js
│ │ │ ├── axios.js.map
│ │ │ ├── axios.min.js
│ │ │ ├── axios.min.js.map
│ │ │ ├── browser
│ │ │ │ ├── axios.cjs
│ │ │ │ └── axios.cjs.map
│ │ │ ├── esm
│ │ │ │ ├── axios.js
│ │ │ │ ├── axios.js.map
│ │ │ │ ├── axios.min.js
│ │ │ │ └── axios.min.js.map
│ │ │ └── node
│ │ │ ├── axios.cjs
│ │ │ └── axios.cjs.map
│ │ ├── index.d.cts
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ ├── lib
│ │ │ ├── adapters
│ │ │ │ ├── adapters.js
│ │ │ │ ├── fetch.js
│ │ │ │ ├── http.js
│ │ │ │ ├── README.md
│ │ │ │ └── xhr.js
│ │ │ ├── axios.js
│ │ │ ├── cancel
│ │ │ │ ├── CanceledError.js
│ │ │ │ ├── CancelToken.js
│ │ │ │ └── isCancel.js
│ │ │ ├── core
│ │ │ │ ├── Axios.js
│ │ │ │ ├── AxiosError.js
│ │ │ │ ├── AxiosHeaders.js
│ │ │ │ ├── buildFullPath.js
│ │ │ │ ├── dispatchRequest.js
│ │ │ │ ├── InterceptorManager.js
│ │ │ │ ├── mergeConfig.js
│ │ │ │ ├── README.md
│ │ │ │ ├── settle.js
│ │ │ │ └── transformData.js
│ │ │ ├── defaults
│ │ │ │ ├── index.js
│ │ │ │ └── transitional.js
│ │ │ ├── env
│ │ │ │ ├── classes
│ │ │ │ │ └── FormData.js
│ │ │ │ ├── data.js
│ │ │ │ └── README.md
│ │ │ ├── helpers
│ │ │ │ ├── AxiosTransformStream.js
│ │ │ │ ├── AxiosURLSearchParams.js
│ │ │ │ ├── bind.js
│ │ │ │ ├── buildURL.js
│ │ │ │ ├── callbackify.js
│ │ │ │ ├── combineURLs.js
│ │ │ │ ├── composeSignals.js
│ │ │ │ ├── cookies.js
│ │ │ │ ├── deprecatedMethod.js
│ │ │ │ ├── formDataToJSON.js
│ │ │ │ ├── formDataToStream.js
│ │ │ │ ├── fromDataURI.js
│ │ │ │ ├── HttpStatusCode.js
│ │ │ │ ├── isAbsoluteURL.js
│ │ │ │ ├── isAxiosError.js
│ │ │ │ ├── isURLSameOrigin.js
│ │ │ │ ├── null.js
│ │ │ │ ├── parseHeaders.js
│ │ │ │ ├── parseProtocol.js
│ │ │ │ ├── progressEventReducer.js
│ │ │ │ ├── readBlob.js
│ │ │ │ ├── README.md
│ │ │ │ ├── resolveConfig.js
│ │ │ │ ├── speedometer.js
│ │ │ │ ├── spread.js
│ │ │ │ ├── throttle.js
│ │ │ │ ├── toFormData.js
│ │ │ │ ├── toURLEncodedForm.js
│ │ │ │ ├── trackStream.js
│ │ │ │ ├── validator.js
│ │ │ │ └── ZlibHeaderTransformStream.js
│ │ │ ├── platform
│ │ │ │ ├── browser
│ │ │ │ │ ├── classes
│ │ │ │ │ │ ├── Blob.js
│ │ │ │ │ │ ├── FormData.js
│ │ │ │ │ │ └── URLSearchParams.js
│ │ │ │ │ └── index.js
│ │ │ │ ├── common
│ │ │ │ │ └── utils.js
│ │ │ │ ├── index.js
│ │ │ │ └── node
│ │ │ │ ├── classes
│ │ │ │ │ ├── FormData.js
│ │ │ │ │ └── URLSearchParams.js
│ │ │ │ └── index.js
│ │ │ └── utils.js
│ │ ├── LICENSE
│ │ ├── MIGRATION_GUIDE.md
│ │ ├── package.json
│ │ ├── README.md
│ │ └── SECURITY.md
│ ├── bytes
│ │ ├── History.md
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── Readme.md
│ ├── combined-stream
│ │ ├── lib
│ │ │ └── combined_stream.js
│ │ ├── License
│ │ ├── package.json
│ │ ├── Readme.md
│ │ └── yarn.lock
│ ├── content-type
│ │ ├── HISTORY.md
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ ├── delayed-stream
│ │ ├── .npmignore
│ │ ├── lib
│ │ │ └── delayed_stream.js
│ │ ├── License
│ │ ├── Makefile
│ │ ├── package.json
│ │ └── Readme.md
│ ├── depd
│ │ ├── History.md
│ │ ├── index.js
│ │ ├── lib
│ │ │ └── browser
│ │ │ └── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── Readme.md
│ ├── follow-redirects
│ │ ├── debug.js
│ │ ├── http.js
│ │ ├── https.js
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ ├── form-data
│ │ ├── index.d.ts
│ │ ├── lib
│ │ │ ├── browser.js
│ │ │ ├── form_data.js
│ │ │ └── populate.js
│ │ ├── License
│ │ ├── package.json
│ │ └── Readme.md
│ ├── http-errors
│ │ ├── HISTORY.md
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ ├── iconv-lite
│ │ ├── .github
│ │ │ └── dependabot.yml
│ │ ├── .idea
│ │ │ ├── codeStyles
│ │ │ │ ├── codeStyleConfig.xml
│ │ │ │ └── Project.xml
│ │ │ ├── iconv-lite.iml
│ │ │ ├── inspectionProfiles
│ │ │ │ └── Project_Default.xml
│ │ │ ├── modules.xml
│ │ │ └── vcs.xml
│ │ ├── Changelog.md
│ │ ├── encodings
│ │ │ ├── dbcs-codec.js
│ │ │ ├── dbcs-data.js
│ │ │ ├── index.js
│ │ │ ├── internal.js
│ │ │ ├── sbcs-codec.js
│ │ │ ├── sbcs-data-generated.js
│ │ │ ├── sbcs-data.js
│ │ │ ├── tables
│ │ │ │ ├── big5-added.json
│ │ │ │ ├── cp936.json
│ │ │ │ ├── cp949.json
│ │ │ │ ├── cp950.json
│ │ │ │ ├── eucjp.json
│ │ │ │ ├── gb18030-ranges.json
│ │ │ │ ├── gbk-added.json
│ │ │ │ └── shiftjis.json
│ │ │ ├── utf16.js
│ │ │ ├── utf32.js
│ │ │ └── utf7.js
│ │ ├── lib
│ │ │ ├── bom-handling.js
│ │ │ ├── index.d.ts
│ │ │ ├── index.js
│ │ │ └── streams.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ ├── inherits
│ │ ├── inherits_browser.js
│ │ ├── inherits.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ ├── mime-db
│ │ ├── db.json
│ │ ├── HISTORY.md
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ ├── mime-types
│ │ ├── HISTORY.md
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ ├── proxy-from-env
│ │ ├── .eslintrc
│ │ ├── .travis.yml
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ ├── README.md
│ │ └── test.js
│ ├── raw-body
│ │ ├── HISTORY.md
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ ├── README.md
│ │ └── SECURITY.md
│ ├── safer-buffer
│ │ ├── dangerous.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ ├── Porting-Buffer.md
│ │ ├── Readme.md
│ │ ├── safer.js
│ │ └── tests.js
│ ├── setprototypeof
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ ├── README.md
│ │ └── test
│ │ └── index.js
│ ├── statuses
│ │ ├── codes.json
│ │ ├── HISTORY.md
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ ├── toidentifier
│ │ ├── HISTORY.md
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ ├── typescript
│ │ ├── bin
│ │ │ ├── tsc
│ │ │ └── tsserver
│ │ ├── lib
│ │ │ ├── _tsc.js
│ │ │ ├── _tsserver.js
│ │ │ ├── _typingsInstaller.js
│ │ │ ├── cancellationToken.js
│ │ │ ├── cs
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ ├── de
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ ├── es
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ ├── fr
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ ├── it
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ ├── ja
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ ├── ko
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ ├── lib.d.ts
│ │ │ ├── lib.decorators.d.ts
│ │ │ ├── lib.decorators.legacy.d.ts
│ │ │ ├── lib.dom.asynciterable.d.ts
│ │ │ ├── lib.dom.d.ts
│ │ │ ├── lib.dom.iterable.d.ts
│ │ │ ├── lib.es2015.collection.d.ts
│ │ │ ├── lib.es2015.core.d.ts
│ │ │ ├── lib.es2015.d.ts
│ │ │ ├── lib.es2015.generator.d.ts
│ │ │ ├── lib.es2015.iterable.d.ts
│ │ │ ├── lib.es2015.promise.d.ts
│ │ │ ├── lib.es2015.proxy.d.ts
│ │ │ ├── lib.es2015.reflect.d.ts
│ │ │ ├── lib.es2015.symbol.d.ts
│ │ │ ├── lib.es2015.symbol.wellknown.d.ts
│ │ │ ├── lib.es2016.array.include.d.ts
│ │ │ ├── lib.es2016.d.ts
│ │ │ ├── lib.es2016.full.d.ts
│ │ │ ├── lib.es2016.intl.d.ts
│ │ │ ├── lib.es2017.arraybuffer.d.ts
│ │ │ ├── lib.es2017.d.ts
│ │ │ ├── lib.es2017.date.d.ts
│ │ │ ├── lib.es2017.full.d.ts
│ │ │ ├── lib.es2017.intl.d.ts
│ │ │ ├── lib.es2017.object.d.ts
│ │ │ ├── lib.es2017.sharedmemory.d.ts
│ │ │ ├── lib.es2017.string.d.ts
│ │ │ ├── lib.es2017.typedarrays.d.ts
│ │ │ ├── lib.es2018.asyncgenerator.d.ts
│ │ │ ├── lib.es2018.asynciterable.d.ts
│ │ │ ├── lib.es2018.d.ts
│ │ │ ├── lib.es2018.full.d.ts
│ │ │ ├── lib.es2018.intl.d.ts
│ │ │ ├── lib.es2018.promise.d.ts
│ │ │ ├── lib.es2018.regexp.d.ts
│ │ │ ├── lib.es2019.array.d.ts
│ │ │ ├── lib.es2019.d.ts
│ │ │ ├── lib.es2019.full.d.ts
│ │ │ ├── lib.es2019.intl.d.ts
│ │ │ ├── lib.es2019.object.d.ts
│ │ │ ├── lib.es2019.string.d.ts
│ │ │ ├── lib.es2019.symbol.d.ts
│ │ │ ├── lib.es2020.bigint.d.ts
│ │ │ ├── lib.es2020.d.ts
│ │ │ ├── lib.es2020.date.d.ts
│ │ │ ├── lib.es2020.full.d.ts
│ │ │ ├── lib.es2020.intl.d.ts
│ │ │ ├── lib.es2020.number.d.ts
│ │ │ ├── lib.es2020.promise.d.ts
│ │ │ ├── lib.es2020.sharedmemory.d.ts
│ │ │ ├── lib.es2020.string.d.ts
│ │ │ ├── lib.es2020.symbol.wellknown.d.ts
│ │ │ ├── lib.es2021.d.ts
│ │ │ ├── lib.es2021.full.d.ts
│ │ │ ├── lib.es2021.intl.d.ts
│ │ │ ├── lib.es2021.promise.d.ts
│ │ │ ├── lib.es2021.string.d.ts
│ │ │ ├── lib.es2021.weakref.d.ts
│ │ │ ├── lib.es2022.array.d.ts
│ │ │ ├── lib.es2022.d.ts
│ │ │ ├── lib.es2022.error.d.ts
│ │ │ ├── lib.es2022.full.d.ts
│ │ │ ├── lib.es2022.intl.d.ts
│ │ │ ├── lib.es2022.object.d.ts
│ │ │ ├── lib.es2022.regexp.d.ts
│ │ │ ├── lib.es2022.string.d.ts
│ │ │ ├── lib.es2023.array.d.ts
│ │ │ ├── lib.es2023.collection.d.ts
│ │ │ ├── lib.es2023.d.ts
│ │ │ ├── lib.es2023.full.d.ts
│ │ │ ├── lib.es2023.intl.d.ts
│ │ │ ├── lib.es2024.arraybuffer.d.ts
│ │ │ ├── lib.es2024.collection.d.ts
│ │ │ ├── lib.es2024.d.ts
│ │ │ ├── lib.es2024.full.d.ts
│ │ │ ├── lib.es2024.object.d.ts
│ │ │ ├── lib.es2024.promise.d.ts
│ │ │ ├── lib.es2024.regexp.d.ts
│ │ │ ├── lib.es2024.sharedmemory.d.ts
│ │ │ ├── lib.es2024.string.d.ts
│ │ │ ├── lib.es5.d.ts
│ │ │ ├── lib.es6.d.ts
│ │ │ ├── lib.esnext.array.d.ts
│ │ │ ├── lib.esnext.collection.d.ts
│ │ │ ├── lib.esnext.d.ts
│ │ │ ├── lib.esnext.decorators.d.ts
│ │ │ ├── lib.esnext.disposable.d.ts
│ │ │ ├── lib.esnext.full.d.ts
│ │ │ ├── lib.esnext.intl.d.ts
│ │ │ ├── lib.esnext.iterator.d.ts
│ │ │ ├── lib.scripthost.d.ts
│ │ │ ├── lib.webworker.asynciterable.d.ts
│ │ │ ├── lib.webworker.d.ts
│ │ │ ├── lib.webworker.importscripts.d.ts
│ │ │ ├── lib.webworker.iterable.d.ts
│ │ │ ├── pl
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ ├── pt-br
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ ├── ru
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ ├── tr
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ ├── tsc.js
│ │ │ ├── tsserver.js
│ │ │ ├── tsserverlibrary.d.ts
│ │ │ ├── tsserverlibrary.js
│ │ │ ├── typescript.d.ts
│ │ │ ├── typescript.js
│ │ │ ├── typesMap.json
│ │ │ ├── typingsInstaller.js
│ │ │ ├── watchGuard.js
│ │ │ ├── zh-cn
│ │ │ │ └── diagnosticMessages.generated.json
│ │ │ └── zh-tw
│ │ │ └── diagnosticMessages.generated.json
│ │ ├── LICENSE.txt
│ │ ├── package.json
│ │ ├── README.md
│ │ ├── SECURITY.md
│ │ └── ThirdPartyNoticeText.txt
│ ├── undici-types
│ │ ├── agent.d.ts
│ │ ├── api.d.ts
│ │ ├── balanced-pool.d.ts
│ │ ├── cache.d.ts
│ │ ├── client.d.ts
│ │ ├── connector.d.ts
│ │ ├── content-type.d.ts
│ │ ├── cookies.d.ts
│ │ ├── diagnostics-channel.d.ts
│ │ ├── dispatcher.d.ts
│ │ ├── env-http-proxy-agent.d.ts
│ │ ├── errors.d.ts
│ │ ├── eventsource.d.ts
│ │ ├── fetch.d.ts
│ │ ├── file.d.ts
│ │ ├── filereader.d.ts
│ │ ├── formdata.d.ts
│ │ ├── global-dispatcher.d.ts
│ │ ├── global-origin.d.ts
│ │ ├── handlers.d.ts
│ │ ├── header.d.ts
│ │ ├── index.d.ts
│ │ ├── interceptors.d.ts
│ │ ├── LICENSE
│ │ ├── mock-agent.d.ts
│ │ ├── mock-client.d.ts
│ │ ├── mock-errors.d.ts
│ │ ├── mock-interceptor.d.ts
│ │ ├── mock-pool.d.ts
│ │ ├── package.json
│ │ ├── patch.d.ts
│ │ ├── pool-stats.d.ts
│ │ ├── pool.d.ts
│ │ ├── proxy-agent.d.ts
│ │ ├── readable.d.ts
│ │ ├── README.md
│ │ ├── retry-agent.d.ts
│ │ ├── retry-handler.d.ts
│ │ ├── util.d.ts
│ │ ├── webidl.d.ts
│ │ └── websocket.d.ts
│ ├── unpipe
│ │ ├── HISTORY.md
│ │ ├── index.js
│ │ ├── LICENSE
│ │ ├── package.json
│ │ └── README.md
│ └── zod
│ ├── index.d.ts
│ ├── lib
│ │ ├── __tests__
│ │ │ ├── Mocker.d.ts
│ │ │ └── Mocker.js
│ │ ├── benchmarks
│ │ │ ├── datetime.d.ts
│ │ │ ├── datetime.js
│ │ │ ├── discriminatedUnion.d.ts
│ │ │ ├── discriminatedUnion.js
│ │ │ ├── index.d.ts
│ │ │ ├── index.js
│ │ │ ├── ipv4.d.ts
│ │ │ ├── ipv4.js
│ │ │ ├── object.d.ts
│ │ │ ├── object.js
│ │ │ ├── primitives.d.ts
│ │ │ ├── primitives.js
│ │ │ ├── realworld.d.ts
│ │ │ ├── realworld.js
│ │ │ ├── string.d.ts
│ │ │ ├── string.js
│ │ │ ├── union.d.ts
│ │ │ └── union.js
│ │ ├── errors.d.ts
│ │ ├── errors.js
│ │ ├── external.d.ts
│ │ ├── external.js
│ │ ├── helpers
│ │ │ ├── enumUtil.d.ts
│ │ │ ├── enumUtil.js
│ │ │ ├── errorUtil.d.ts
│ │ │ ├── errorUtil.js
│ │ │ ├── parseUtil.d.ts
│ │ │ ├── parseUtil.js
│ │ │ ├── partialUtil.d.ts
│ │ │ ├── partialUtil.js
│ │ │ ├── typeAliases.d.ts
│ │ │ ├── typeAliases.js
│ │ │ ├── util.d.ts
│ │ │ └── util.js
│ │ ├── index.d.ts
│ │ ├── index.js
│ │ ├── index.mjs
│ │ ├── index.umd.js
│ │ ├── locales
│ │ │ ├── en.d.ts
│ │ │ └── en.js
│ │ ├── standard-schema.d.ts
│ │ ├── standard-schema.js
│ │ ├── types.d.ts
│ │ ├── types.js
│ │ ├── ZodError.d.ts
│ │ └── ZodError.js
│ ├── LICENSE
│ ├── package.json
│ └── README.md
├── package-lock.json
├── package.json
├── README.md
├── src
│ ├── cache.ts
│ ├── index.ts
│ ├── tool-chain.ts
│ └── types.ts
├── test
│ └── test-chain.js
└── tsconfig.json
```
# Files
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
```markdown
1 | # DeepSeek MCP Server
2 |
3 | An MCP server implementation that provides code generation and completion capabilities using the DeepSeek API, with support for tool chaining and cost optimization.
4 |
5 | ## Features
6 |
7 | - Code generation with language-specific support
8 | - Code completion with context awareness
9 | - Code optimization with multiple targets
10 | - Tool chaining for complex operations
11 | - Built-in caching for cost optimization
12 | - TypeScript implementation with full type safety
13 |
14 | ## Tools
15 |
16 | ### 1. generate_code
17 | Generate code using DeepSeek API with language-specific support.
18 | ```json
19 | {
20 | "name": "generate_code",
21 | "params": {
22 | "prompt": "Write a function that sorts an array",
23 | "language": "typescript",
24 | "temperature": 0.7
25 | }
26 | }
27 | ```
28 |
29 | ### 2. complete_code
30 | Get intelligent code completions based on existing context.
31 | ```json
32 | {
33 | "name": "complete_code",
34 | "params": {
35 | "code": "function processData(data) {",
36 | "prompt": "Add input validation and error handling",
37 | "temperature": 0.7
38 | }
39 | }
40 | ```
41 |
42 | ### 3. optimize_code
43 | Optimize existing code for performance, memory usage, or readability.
44 | ```json
45 | {
46 | "name": "optimize_code",
47 | "params": {
48 | "code": "your code here",
49 | "target": "performance"
50 | }
51 | }
52 | ```
53 |
54 | ### 4. execute_chain
55 | Execute a chain of tools in sequence, with context passing between steps.
56 | ```json
57 | {
58 | "name": "execute_chain",
59 | "params": {
60 | "steps": [
61 | {
62 | "toolName": "generate_code",
63 | "params": {
64 | "prompt": "Create a REST API endpoint",
65 | "language": "typescript"
66 | }
67 | },
68 | {
69 | "toolName": "optimize_code",
70 | "params": {
71 | "target": "performance"
72 | }
73 | }
74 | ]
75 | }
76 | }
77 | ```
78 |
79 | ## Installation
80 |
81 | 1. Clone the repository
82 | 2. Install dependencies:
83 | ```bash
84 | npm install
85 | ```
86 |
87 | 3. Build the project:
88 | ```bash
89 | npm run build
90 | ```
91 |
92 | 4. Configure your DeepSeek API key in the MCP settings file:
93 | ```json
94 | {
95 | "mcpServers": {
96 | "deepseek": {
97 | "command": "node",
98 | "args": ["/path/to/deepseek-mcp/build/index.js"],
99 | "env": {
100 | "DEEPSEEK_API_KEY": "your-api-key"
101 | }
102 | }
103 | }
104 | }
105 | ```
106 |
107 | ## Usage
108 |
109 | The server can be used with any MCP-compatible client. Here's an example using the MCP CLI:
110 |
111 | ```bash
112 | mcp use deepseek generate_code --params '{"prompt": "Write a hello world program", "language": "python"}'
113 | ```
114 |
115 | ## Tool Chaining
116 |
117 | Tool chaining allows you to combine multiple operations into a single workflow. Each tool in the chain can access the results of previous tools through the chain context.
118 |
119 | Example chain:
120 | 1. Generate initial code
121 | 2. Complete the code with error handling
122 | 3. Optimize the final result
123 |
124 | ```json
125 | {
126 | "steps": [
127 | {
128 | "toolName": "generate_code",
129 | "params": {
130 | "prompt": "Create a user authentication function",
131 | "language": "typescript"
132 | }
133 | },
134 | {
135 | "toolName": "complete_code",
136 | "params": {
137 | "prompt": "Add input validation and error handling"
138 | }
139 | },
140 | {
141 | "toolName": "optimize_code",
142 | "params": {
143 | "target": "security"
144 | }
145 | }
146 | ]
147 | }
148 | ```
149 |
150 | ## Cost Optimization
151 |
152 | The server implements several strategies to optimize API costs:
153 |
154 | 1. Request caching with TTL
155 | 2. Chain result caching
156 | 3. Smart prompt construction
157 | 4. Metadata tracking for usage analysis
158 |
159 | ## Development
160 |
161 | To start development:
162 |
163 | ```bash
164 | npm run dev
165 | ```
166 |
167 | To clean and rebuild:
168 |
169 | ```bash
170 | npm run rebuild
171 | ```
172 |
173 | ## Requirements
174 |
175 | - Node.js >= 18.0.0
176 | - DeepSeek API key
177 | - MCP-compatible client
178 |
179 | ## License
180 |
181 | ISC
182 |
```
--------------------------------------------------------------------------------
/config-example.json:
--------------------------------------------------------------------------------
```json
1 | {
2 | "mcpServers": {
3 | "deepseek": {
4 | "command": "node",
5 | "args": ["PATH_TO_SERVER/build/index.js"],
6 | "env": {
7 | "DEEPSEEK_API_KEY": "your-api-key-here",
8 | "NODE_ENV": "production"
9 | }
10 | }
11 | }
12 | }
13 |
```
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
```json
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "module": "ES2020",
5 | "moduleResolution": "node",
6 | "outDir": "./build",
7 | "rootDir": "./src",
8 | "strict": true,
9 | "esModuleInterop": true,
10 | "skipLibCheck": true,
11 | "forceConsistentCasingInFileNames": true
12 | },
13 | "include": ["src/**/*"],
14 | "exclude": ["node_modules"]
15 | }
16 |
```
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
```json
1 | {
2 | "name": "deepseek-mcp",
3 | "version": "1.0.0",
4 | "description": "DeepSeek MCP Server for code generation and completion",
5 | "main": "build/index.js",
6 | "type": "module",
7 | "scripts": {
8 | "build": "tsc && chmod +x build/index.js",
9 | "start": "node build/index.js",
10 | "dev": "tsc -w",
11 | "clean": "rm -rf build",
12 | "rebuild": "npm run clean && npm run build"
13 | },
14 | "keywords": ["mcp", "deepseek", "ai", "code-generation"],
15 | "author": "",
16 | "license": "ISC",
17 | "dependencies": {
18 | "@modelcontextprotocol/sdk": "latest",
19 | "axios": "^1.6.0"
20 | },
21 | "devDependencies": {
22 | "@types/node": "^20.0.0",
23 | "typescript": "^5.0.0"
24 | },
25 | "engines": {
26 | "node": ">=18.0.0"
27 | }
28 | }
29 |
```
--------------------------------------------------------------------------------
/src/types.ts:
--------------------------------------------------------------------------------
```typescript
1 | export interface ToolChainContext {
2 | previousResults: any[];
3 | metadata: Record<string, any>;
4 | }
5 |
6 | export interface DeepSeekResponse {
7 | text: string;
8 | usage: {
9 | prompt_tokens: number;
10 | completion_tokens: number;
11 | };
12 | }
13 |
14 | export interface CacheEntry {
15 | result: string;
16 | timestamp: number;
17 | ttl: number;
18 | metadata?: Record<string, any>;
19 | }
20 |
21 | export interface ToolResult {
22 | success: boolean;
23 | result: any;
24 | error?: string;
25 | metadata?: Record<string, any>;
26 | }
27 |
28 | export interface ChainableToolConfig {
29 | name: string;
30 | description: string;
31 | inputSchema: Record<string, any>;
32 | chainable: boolean;
33 | requiresPrevious?: boolean;
34 | metadataSchema?: Record<string, any>;
35 | }
36 |
37 | export interface ToolChainStep {
38 | toolName: string;
39 | params: Record<string, any>;
40 | metadata?: Record<string, any>;
41 | }
42 |
43 | export interface ToolChain {
44 | steps: ToolChainStep[];
45 | context: ToolChainContext;
46 | }
47 |
```
--------------------------------------------------------------------------------
/test/test-chain.js:
--------------------------------------------------------------------------------
```javascript
1 | #!/usr/bin/env node
2 |
3 | // Example test chain for the DeepSeek MCP server
4 | const chain = {
5 | steps: [
6 | {
7 | toolName: 'generate_code',
8 | params: {
9 | prompt: 'Create a simple Express.js server with one GET endpoint that returns "Hello World"',
10 | language: 'typescript',
11 | temperature: 0.7
12 | }
13 | },
14 | {
15 | toolName: 'optimize_code',
16 | params: {
17 | target: 'performance'
18 | }
19 | }
20 | ]
21 | };
22 |
23 | // Print the chain configuration
24 | console.log('Test Chain Configuration:');
25 | console.log(JSON.stringify(chain, null, 2));
26 |
27 | // Instructions for testing
28 | console.log('\nTo test this chain, run:');
29 | console.log('mcp use deepseek execute_chain --params \'{"steps": ' + JSON.stringify(chain.steps) + '}\'');
30 |
31 | // Note about environment setup
32 | console.log('\nMake sure to:');
33 | console.log('1. Set DEEPSEEK_API_KEY in your MCP settings');
34 | console.log('2. Add the DeepSeek MCP server to your MCP configuration');
35 | console.log('3. Start the server using: npm start');
36 |
```
--------------------------------------------------------------------------------
/src/cache.ts:
--------------------------------------------------------------------------------
```typescript
1 | import { CacheEntry } from './types';
2 |
3 | export class Cache {
4 | private store: Map<string, CacheEntry>;
5 |
6 | constructor() {
7 | this.store = new Map();
8 | }
9 |
10 | get(key: string): string | null {
11 | const entry = this.store.get(key);
12 | if (!entry) return null;
13 |
14 | const now = Date.now();
15 | if (now - entry.timestamp > entry.ttl * 1000) {
16 | this.store.delete(key);
17 | return null;
18 | }
19 |
20 | return entry.result;
21 | }
22 |
23 | set(key: string, result: string, ttl: number, metadata?: Record<string, any>): void {
24 | this.store.set(key, {
25 | result,
26 | timestamp: Date.now(),
27 | ttl,
28 | metadata
29 | });
30 | }
31 |
32 | getMetadata(key: string): Record<string, any> | null {
33 | const entry = this.store.get(key);
34 | return entry?.metadata || null;
35 | }
36 |
37 | has(key: string): boolean {
38 | return this.get(key) !== null;
39 | }
40 |
41 | delete(key: string): void {
42 | this.store.delete(key);
43 | }
44 |
45 | clear(): void {
46 | this.store.clear();
47 | }
48 |
49 | // Helper method to generate cache keys for tool chains
50 | static generateChainKey(steps: { toolName: string; params: any }[]): string {
51 | return steps.map(step =>
52 | `${step.toolName}:${JSON.stringify(step.params)}`
53 | ).join('|');
54 | }
55 |
56 | // Cleanup expired entries
57 | cleanup(): void {
58 | const now = Date.now();
59 | for (const [key, entry] of this.store.entries()) {
60 | if (now - entry.timestamp > entry.ttl * 1000) {
61 | this.store.delete(key);
62 | }
63 | }
64 | }
65 | }
66 |
```
--------------------------------------------------------------------------------
/src/tool-chain.ts:
--------------------------------------------------------------------------------
```typescript
1 | import { ToolChain, ToolChainContext, ToolChainStep, ToolResult, ChainableToolConfig } from './types';
2 | import { Cache } from './cache';
3 |
4 | interface SchemaProperty {
5 | type: string;
6 | description?: string;
7 | }
8 |
9 | interface ValidationSchema {
10 | properties: Record<string, SchemaProperty>;
11 | required?: string[];
12 | }
13 |
14 | export class ToolChainManager {
15 | private tools: Map<string, ChainableToolConfig>;
16 | private cache: Cache;
17 |
18 | constructor() {
19 | this.tools = new Map();
20 | this.cache = new Cache();
21 | }
22 |
23 | registerTool(config: ChainableToolConfig): void {
24 | this.tools.set(config.name, config);
25 | }
26 |
27 | async executeChain(chain: ToolChain): Promise<ToolResult[]> {
28 | const results: ToolResult[] = [];
29 | const context: ToolChainContext = {
30 | previousResults: [],
31 | metadata: {}
32 | };
33 |
34 | // Check cache for entire chain result
35 | const chainKey = Cache.generateChainKey(chain.steps);
36 | const cachedResult = this.cache.get(chainKey);
37 | if (cachedResult) {
38 | try {
39 | const parsed = JSON.parse(cachedResult);
40 | return parsed;
41 | } catch (error) {
42 | console.error('Error parsing cached chain result:', error);
43 | }
44 | }
45 |
46 | // Execute each step in the chain
47 | for (const step of chain.steps) {
48 | try {
49 | const result = await this.executeStep(step, context);
50 | results.push(result);
51 |
52 | if (!result.success) {
53 | break; // Stop chain execution on failure
54 | }
55 |
56 | // Update context for next step
57 | context.previousResults.push(result);
58 | if (result.metadata) {
59 | context.metadata = { ...context.metadata, ...result.metadata };
60 | }
61 | } catch (error) {
62 | results.push({
63 | success: false,
64 | result: null,
65 | error: error instanceof Error ? error.message : 'Unknown error'
66 | });
67 | break;
68 | }
69 | }
70 |
71 | // Cache successful chain results
72 | if (results.every(r => r.success)) {
73 | this.cache.set(chainKey, JSON.stringify(results), 3600); // 1 hour TTL
74 | }
75 |
76 | return results;
77 | }
78 |
79 | private async executeStep(step: ToolChainStep, context: ToolChainContext): Promise<ToolResult> {
80 | const tool = this.tools.get(step.toolName);
81 | if (!tool) {
82 | throw new Error(`Tool not found: ${step.toolName}`);
83 | }
84 |
85 | // Validate tool requirements
86 | if (tool.requiresPrevious && context.previousResults.length === 0) {
87 | throw new Error(`Tool ${step.toolName} requires previous results`);
88 | }
89 |
90 | // Validate input parameters
91 | this.validateParams(step.params, tool.inputSchema as ValidationSchema);
92 |
93 | // Check step-level cache
94 | const stepKey = `${step.toolName}:${JSON.stringify(step.params)}`;
95 | const cachedResult = this.cache.get(stepKey);
96 | if (cachedResult) {
97 | try {
98 | return JSON.parse(cachedResult);
99 | } catch (error) {
100 | console.error('Error parsing cached step result:', error);
101 | }
102 | }
103 |
104 | try {
105 | // Execute tool with context
106 | const result: ToolResult = {
107 | success: true,
108 | result: await this.executeTool(tool, step.params, context),
109 | metadata: step.metadata
110 | };
111 |
112 | // Cache successful results
113 | this.cache.set(stepKey, JSON.stringify(result), 3600); // 1 hour TTL
114 | return result;
115 | } catch (error) {
116 | return {
117 | success: false,
118 | result: null,
119 | error: error instanceof Error ? error.message : 'Unknown error',
120 | metadata: step.metadata
121 | };
122 | }
123 | }
124 |
125 | private async executeTool(
126 | tool: ChainableToolConfig,
127 | params: Record<string, any>,
128 | context: ToolChainContext
129 | ): Promise<any> {
130 | // This would be implemented by the specific tool handler
131 | throw new Error('Tool execution not implemented');
132 | }
133 |
134 | private validateParams(params: Record<string, any>, schema: ValidationSchema): void {
135 | // Basic schema validation
136 | for (const [key, value] of Object.entries(schema.properties)) {
137 | if (schema.required?.includes(key) && !(key in params)) {
138 | throw new Error(`Missing required parameter: ${key}`);
139 | }
140 |
141 | if (key in params) {
142 | const paramValue = params[key];
143 | if (value.type && typeof paramValue !== value.type) {
144 | throw new Error(`Invalid type for parameter ${key}: expected ${value.type}, got ${typeof paramValue}`);
145 | }
146 | }
147 | }
148 | }
149 |
150 | // Helper methods for chain manipulation
151 | addStep(chain: ToolChain, step: ToolChainStep): void {
152 | chain.steps.push(step);
153 | }
154 |
155 | removeStep(chain: ToolChain, index: number): void {
156 | chain.steps.splice(index, 1);
157 | }
158 |
159 | clearChain(chain: ToolChain): void {
160 | chain.steps = [];
161 | chain.context = { previousResults: [], metadata: {} };
162 | }
163 | }
164 |
```
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
```typescript
1 | #!/usr/bin/env node
2 | import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3 | import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4 | import {
5 | CallToolRequestSchema,
6 | ListToolsRequestSchema,
7 | Request
8 | } from '@modelcontextprotocol/sdk/types.js';
9 | import axios, { AxiosError } from 'axios';
10 | import { ToolChainManager } from './tool-chain';
11 | import { ChainableToolConfig, ToolChain } from './types';
12 |
13 | interface ToolRequest extends Request {
14 | params: {
15 | name: string;
16 | arguments: Record<string, unknown>;
17 | };
18 | }
19 |
20 | interface ChainStep {
21 | toolName: string;
22 | params: Record<string, unknown>;
23 | }
24 |
25 | interface ChainRequest extends Request {
26 | params: {
27 | name: string;
28 | arguments: {
29 | steps: ChainStep[];
30 | };
31 | };
32 | }
33 |
34 | const API_KEY = process.env.DEEPSEEK_API_KEY;
35 | if (!API_KEY) {
36 | throw new Error('DEEPSEEK_API_KEY environment variable is required');
37 | }
38 |
39 | interface DeepSeekResponse {
40 | choices: Array<{
41 | text: string;
42 | }>;
43 | }
44 |
45 | class DeepSeekServer {
46 | private server: Server;
47 | private chainManager: ToolChainManager;
48 | private axiosInstance;
49 |
50 | constructor() {
51 | this.server = new Server(
52 | {
53 | name: 'deepseek-server',
54 | version: '0.1.0',
55 | },
56 | {
57 | capabilities: {
58 | tools: {},
59 | },
60 | }
61 | );
62 |
63 | this.chainManager = new ToolChainManager();
64 |
65 | this.axiosInstance = axios.create({
66 | baseURL: 'https://api.deepseek.com/v1',
67 | headers: {
68 | 'Authorization': `Bearer ${API_KEY}`,
69 | 'Content-Type': 'application/json',
70 | },
71 | });
72 |
73 | this.setupTools();
74 | this.setupErrorHandling();
75 | }
76 |
77 | private setupTools(): void {
78 | // Code Generation Tool
79 | const generateCodeConfig: ChainableToolConfig = {
80 | name: 'generate_code',
81 | description: 'Generate code using DeepSeek API',
82 | chainable: true,
83 | inputSchema: {
84 | properties: {
85 | prompt: {
86 | type: 'string',
87 | description: 'The code generation prompt'
88 | },
89 | language: {
90 | type: 'string',
91 | description: 'Target programming language'
92 | },
93 | temperature: {
94 | type: 'number',
95 | description: 'Sampling temperature (0-1)'
96 | }
97 | },
98 | required: ['prompt']
99 | }
100 | };
101 |
102 | // Code Completion Tool
103 | const completeCodeConfig: ChainableToolConfig = {
104 | name: 'complete_code',
105 | description: 'Get code completions using DeepSeek',
106 | chainable: true,
107 | inputSchema: {
108 | properties: {
109 | code: {
110 | type: 'string',
111 | description: 'Existing code context'
112 | },
113 | prompt: {
114 | type: 'string',
115 | description: 'Completion prompt'
116 | },
117 | temperature: {
118 | type: 'number',
119 | description: 'Sampling temperature'
120 | }
121 | },
122 | required: ['code', 'prompt']
123 | }
124 | };
125 |
126 | // Code Optimization Tool
127 | const optimizeCodeConfig: ChainableToolConfig = {
128 | name: 'optimize_code',
129 | description: 'Optimize code using DeepSeek',
130 | chainable: true,
131 | requiresPrevious: true,
132 | inputSchema: {
133 | properties: {
134 | code: {
135 | type: 'string',
136 | description: 'Code to optimize'
137 | },
138 | target: {
139 | type: 'string',
140 | description: 'Optimization target (performance, memory, readability)'
141 | }
142 | },
143 | required: ['code']
144 | }
145 | };
146 |
147 | // Register tools
148 | this.chainManager.registerTool(generateCodeConfig);
149 | this.chainManager.registerTool(completeCodeConfig);
150 | this.chainManager.registerTool(optimizeCodeConfig);
151 |
152 | // Set up MCP tool handlers
153 | this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
154 | tools: [
155 | {
156 | name: 'generate_code',
157 | description: 'Generate code using DeepSeek API',
158 | inputSchema: generateCodeConfig.inputSchema
159 | },
160 | {
161 | name: 'complete_code',
162 | description: 'Get code completions using DeepSeek',
163 | inputSchema: completeCodeConfig.inputSchema
164 | },
165 | {
166 | name: 'optimize_code',
167 | description: 'Optimize code using DeepSeek',
168 | inputSchema: optimizeCodeConfig.inputSchema
169 | },
170 | {
171 | name: 'execute_chain',
172 | description: 'Execute a chain of DeepSeek tools',
173 | inputSchema: {
174 | type: 'object',
175 | properties: {
176 | steps: {
177 | type: 'array',
178 | items: {
179 | type: 'object',
180 | properties: {
181 | toolName: { type: 'string' },
182 | params: { type: 'object' }
183 | },
184 | required: ['toolName', 'params']
185 | }
186 | }
187 | },
188 | required: ['steps']
189 | }
190 | }
191 | ]
192 | }));
193 |
194 | this.server.setRequestHandler(CallToolRequestSchema, async (request: Request) => {
195 | try {
196 | if (!request.params?.name) {
197 | throw new Error('Invalid request: missing tool name');
198 | }
199 |
200 | if (request.params.name === 'execute_chain') {
201 | const chainRequest = request as ChainRequest;
202 | if (!chainRequest.params.arguments?.steps) {
203 | throw new Error('Invalid chain request: missing steps');
204 | }
205 |
206 | const chain: ToolChain = {
207 | steps: chainRequest.params.arguments.steps,
208 | context: { previousResults: [], metadata: {} }
209 | };
210 |
211 | const results = await this.chainManager.executeChain(chain);
212 | return {
213 | content: [{
214 | type: 'text',
215 | text: JSON.stringify(results, null, 2)
216 | }]
217 | };
218 | }
219 |
220 | // Handle individual tool calls
221 | const toolRequest = request as ToolRequest;
222 | const result = await this.handleToolCall(
223 | toolRequest.params.name,
224 | toolRequest.params.arguments
225 | );
226 |
227 | return {
228 | content: [{
229 | type: 'text',
230 | text: result
231 | }]
232 | };
233 | } catch (error: unknown) {
234 | return {
235 | content: [{
236 | type: 'text',
237 | text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`
238 | }],
239 | isError: true
240 | };
241 | }
242 | });
243 | }
244 |
245 | private async handleToolCall(name: string, params: Record<string, unknown>): Promise<string> {
246 | try {
247 | const response = await this.axiosInstance.post<DeepSeekResponse>('/completions', {
248 | prompt: this.buildPrompt(name, params),
249 | temperature: params.temperature || 0.7,
250 | max_tokens: 2000
251 | });
252 |
253 | return response.data.choices[0].text;
254 | } catch (error: unknown) {
255 | if (error instanceof AxiosError) {
256 | throw new Error(`DeepSeek API error: ${error.response?.data?.error || error.message}`);
257 | }
258 | throw error;
259 | }
260 | }
261 |
262 | private buildPrompt(toolName: string, params: Record<string, unknown>): string {
263 | switch (toolName) {
264 | case 'generate_code':
265 | return `
266 | ### Task: Code Generation
267 | ### Language: ${params.language || 'any'}
268 | ### Requirements:
269 | ${params.prompt}
270 | ### Response:
271 | `;
272 |
273 | case 'complete_code':
274 | return `
275 | ### Task: Code Completion
276 | ### Context:
277 | ${params.code}
278 | ### Requirements:
279 | ${params.prompt}
280 | ### Response:
281 | `;
282 |
283 | case 'optimize_code':
284 | return `
285 | ### Task: Code Optimization
286 | ### Target: ${params.target || 'performance'}
287 | ### Code:
288 | ${params.code}
289 | ### Response:
290 | `;
291 |
292 | default:
293 | throw new Error(`Unknown tool: ${toolName}`);
294 | }
295 | }
296 |
297 | private setupErrorHandling(): void {
298 | this.server.onerror = (error: Error) => {
299 | console.error('[MCP Error]', error);
300 | };
301 |
302 | process.on('SIGINT', async () => {
303 | await this.server.close();
304 | process.exit(0);
305 | });
306 | }
307 |
308 | async run(): Promise<void> {
309 | const transport = new StdioServerTransport();
310 | await this.server.connect(transport);
311 | console.error('DeepSeek MCP server running on stdio');
312 | }
313 | }
314 |
315 | const server = new DeepSeekServer();
316 | server.run().catch(console.error);
317 |
```