Skip to content

docs: Add more examples how to use this sdk #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Jun 2, 2025

Conversation

edenreich
Copy link
Contributor

Summary

Add more examples for MCP usage.

Changelog

  • docs(examples): Add example environment configuration and README files for SDK usage
  • docs: Update README to include pre-requisites for using the Typescript SDK examples
  • docs(examples): Update example links in README and add list example README
  • docs(examples): Add examples for chat, list, and MCP using Inference Gateway SDK
  • docs(exmaples): Add sample files and configuration for MCP example
  • docs(examples): Update LLM model references to remove provider prefix
  • docs(mcp): Add note to ensure no containers are running before starting the example
  • feat: Support both local tools and remote MCP tools; Add onMCPTool callback
  • docs(examples): Refactor MCP examples and client for improved error handling and token tracking
  • docs(examples) Add more examples and MCP server to MCP examples
  • docs(examples): Add NPM MCP server with whitelisted command execution and project management tools

edenreich added 11 commits May 27, 2025 18:31
…s for SDK usage

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…t SDK examples

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…EADME

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…Gateway SDK

- Created a chat example with package.json, tsconfig.json, and index.ts to demonstrate chat completions and streaming responses.
- Added a list example with package.json, tsconfig.json, and index.ts for listing models and MCP tools.
- Included README.md files for both chat and list examples with instructions for getting started.
- Added .gitignore files to exclude node_modules in both list and MCP examples.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
- Created a new directory with sample files for the MCP filesystem server, including `sample.txt`, `data.json`, and `config.yaml`.
- Added a README.md file to describe the purpose and usage of the sample data.
- Implemented a TypeScript configuration file (`tsconfig.json`) for the MCP example.
- Created a package.json and package-lock.json for managing dependencies in the examples directory.
- Updated the OpenAPI specification to include new endpoints and improved formatting for consistency.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
…ng the example

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…llback

- Created a new MCP Web Search Server with a package.json file.
- Updated the main MCP package.json to include example scripts for remote and local tools.
- Added a .gitignore file in the shared directory to exclude unnecessary files.
- Removed outdated README.md, config.yaml, data.json, and sample.txt files from the shared directory.
- Introduced a new sample_sales_data.csv file for demonstration purposes.
- Enhanced the client.ts to support MCP tool callbacks and improved streaming response processing.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…andling and token tracking

- Updated docker-compose.yml to set environment to production and commented out optional Ollama service.
- Enhanced example-mcp-tools.ts to use console.info for logging and added model availability checks.
- Modified index.ts to implement token tracking for prompt and completion tokens, displaying usage metrics at the end.
- Improved filesystem MCP server (index.js) to use console.info for logging and ensure consistent messaging.
- Updated web-search MCP server (index-http.js and index.js) to use console.info for logging and improved request handling.
- Enhanced InferenceGatewayClient to handle mid-stream errors and added type definitions for stream chunks that may contain errors.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
… and project management tools

Signed-off-by: Eden Reich <eden.reich@gmail.com>
@edenreich edenreich changed the title docs/add more examples how to use this sdk docs: Add more examples how to use this sdk May 31, 2025
edenreich added 18 commits May 31, 2025 21:58
…s-sdk

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…mmand timeouts

- Renamed mcp-context7-server to context7-http-bridge and updated description in package.json.
- Updated dependencies:
  - Changed @modelcontextprotocol/sdk version to ^0.5.0.
  - Added @upstash/context7-mcp as a dependency.
  - Updated zod to ^3.22.4.
- Changed dev script to use nodemon for development.
- Increased timeout for npm command execution from 30 seconds to 5 minutes.
- Increased timeout for project creation from 3 minutes to 10 minutes.
- Added a clean script to remove shared directories in mcp package.json.
- Renamed example:context7 to example:agent in mcp package.json.
- Increased default timeout in InferenceGatewayClient to 60 seconds.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…pt for Context7 agent

I need to fix in the Inference Gateway or find a solution for DeepSeek 30seconds timeout - it's annoying.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…ion and update system prompt

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…n application development

- Deleted example-npm.ts and example-tool-demo.ts as they are no longer needed.
- Introduced example-vite-agent.ts to facilitate the creation of Vite-based applications.
- Updated package.json to reflect the removal of old examples and the addition of the new Vite agent.
- Cleaned up filesystem server code by removing unnecessary comments and simplifying allowed directories.
- Removed sample_sales_data.csv as it is no longer relevant to the current examples.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
- Created a new package.json for the Vite agent with necessary dependencies and scripts.
- Added a Docker Compose configuration file to manage multiple agents including Kubernetes, Vite, and Next.js.
- Removed the outdated README for MCP servers as part of the restructuring.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…overy

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…d rename tool callback to onMCPTool

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…etion to MCP filesystem server

Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
…index.ts'

Signed-off-by: Eden Reich <eden.reich@gmail.com>
… Inference Gateway and MCP Server

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…rror handling

- Introduced a standardized Winston logger for consistent logging across the MCP server.
- Added middleware for logging incoming requests and their completion details.
- Enhanced error handling in tools, providing structured error responses.
- Implemented HTML content extraction using Cheerio, with options for plain text extraction.
- Updated the fetch_url tool to log detailed fetch operations and handle various content types.
- Improved logging for web search and page title extraction tools.
- Added health check endpoint logging.
- Updated package dependencies to include Winston for logging.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…options

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…r service

Still need to figure out why I cannot connect to the other services using the inspector

Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
…ilesystem Server

Signed-off-by: Eden Reich <eden.reich@gmail.com>
edenreich added 10 commits June 1, 2025 19:46
Signed-off-by: Eden Reich <eden.reich@gmail.com>
… model configuration in multiple agents

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…_tokens settings

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…mory Server

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…logging consistency

Signed-off-by: Eden Reich <eden.reich@gmail.com>
… optimize request handling

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…ry operations

- Removed healthcheck from docker-compose.yml for the MCP service.
- Introduced MemoryManager class for efficient in-memory storage with background persistence.
- Replaced file I/O operations with in-memory methods in index.js for saving, restoring, and managing session data.
- Implemented automatic background persistence for dirty sessions in MemoryManager.
- Enhanced error handling and logging throughout the memory management process.
- Updated server startup and shutdown procedures to integrate MemoryManager lifecycle.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…uration

- Created package.json for the MCP Brave Search server with necessary dependencies and scripts.
- Added tsconfig.json for TypeScript configuration, specifying compiler options and file inclusion/exclusion.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
@edenreich edenreich merged commit 5bddd0b into main Jun 2, 2025
1 check passed
@edenreich edenreich deleted the docs/add-more-examples-how-to-use-this-sdk branch June 2, 2025 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant