Skip to content

Add serverSecurityLogic - #259

Open
max-peroch wants to merge 5 commits into
softwaremill:masterfrom
max-peroch:server-security-logic
Open

max-peroch wants to merge 5 commits into
softwaremill:masterfrom
max-peroch:server-security-logic

Conversation

@max-peroch

Copy link
Copy Markdown

Attempt at addressing #237

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can other MCP "entities" benefit from secured handlers too? ie. Resource and Prompt

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left Resource and Prompt out of this PR so it stays scoped to tools (#237) . The same handleSecured / securedServerLogic shape would work there (and for resource templates) without changing prependSecurity. Happy to add it here if you’d rather have one PR, otherwise I can follow up after this lands?

.transformWith(_ => backend.close())
.transformWith(_ => binding.terminate(5.seconds))
.transform(_ => result)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we avoid some code duplication, it's very similar to the method above (applies to Ox and ZIO too)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason this is not a trait as the secured streaming tests are?

Comment thread docs/server/transport.md Outdated
import sttp.tapir.server.netty.sync.NettySyncServer

object SecuredMcpServer:
object McpServerWithPrependedSecurity:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the previous, simpler name

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had some imports name clash... let me check

import io.circe.Json
import sttp.model.{Header, HeaderNames, StatusCode}
import sttp.monad.MonadError
import sttp.monad.syntax.*

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is private to transport, I think comments are redundant

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.

2 participants